[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Change class of TD cell with JQuery based on Calculated Cell Values

Posted on 2013-06-09
6
Medium Priority
?
344 Views
Last Modified: 2014-09-15
I have the following code that is launched in an AJAX page from SharePoint. I am trying to get the class of the td to change if the value of the calculate cell is greated than zero.

The class name to change to is "red". The table ID is "ost-SubDetailsTable"

Here is the HTML table row code:

<tr id="ost-GapRow">

			<td class="t-column" style="padding:5px;">Gap</td>
			<xsl:if test="$qTargetType = 'Field'">
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'North-East' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed:{count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'North-East' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>		
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'South' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed: {count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'South' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'West' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed: {count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'West' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'Mid-West' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed: {count(dsQueryResponse/Rows/Row[@Sales_x0020_Force = $qFranchiseSpeaker and  @ContentType = 'Field Observations' and @CollapsedCensusRegions  = 'Mid-West' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>
			</xsl:if>
			<xsl:if test="$qTargetType = 'Speaker'">
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@SpeakerBureau = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions = 'North-East' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed: {count(dsQueryResponse/Rows/Row[@SpeakerBureau  = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions  = 'North-East' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@SpeakerBureau = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions  = 'South' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed: {count(dsQueryResponse/Rows/Row[@SpeakerBureau  = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions  = 'South' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>		
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@SpeakerBureau = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions = 'West' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed: {count(dsQueryResponse/Rows/Row[@SpeakerBureau = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions  = 'West' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>
				<td class="t-columngap" style="text-align:center; padding:5px;" title="Scheduled: {count(dsQueryResponse/Rows/Row[@SpeakerBureau = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions  = 'Mid-West' and @ObservationStatus = 'Planned' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}  |  Completed: {count(dsQueryResponse/Rows/Row[@SpeakerBureau  = $qFranchiseSpeaker and  @ContentType = 'Speaker Programs' and @CollapsedCensusRegions  = 'Mid-West' and @ObservationStatus = 'Completed' and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &gt;= $qTargetStart  and ddwrt:FormatDateTime(string(@Date_x0020_of_x0020_Observation), 1033, 'yyyyMMdd') &lt;= $qTargetEnd])}"></td>
			</xsl:if>
	</tr>

Open in new window

0
Comment
Question by:aehrenwo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39233866
Which one is the calc cell?
Which td need to be changed based on that?
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39233883
Hi,
could you please post the generated html code (result)?
Which SharePoint version/edition?
Thanks
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39234040
since change event only works with text fields, text areas and select elements, u need to use SetInterval to check whether the td value has changed and the criteria was matched (greater than zero):
setInterval(function() {			
		$('#ost-GapRow tr td').each(function (i, item) {
			if ($(item).text() > 0) {				 
				  $(item).attr('class', 'red');
			} 
		});
	}, 100);

Open in new window

0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:aehrenwo
ID: 39234360
Thanks for the quick reply. How would it be modified it if I only wanted to check the row that has the final total? let's say that it's called ID "gaprow".
0
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 1500 total points
ID: 39234368
setInterval(function() {			
		var td= $('#ost-GapRow tr td:last');
			if (td.text() > 0) {				 
				  td.attr('class', 'red');
			} 
		});
	}, 100);

Open in new window

0
 

Author Comment

by:aehrenwo
ID: 39238005
I have included this code on the aspx page directly but it doesn't seem to be working.

I think this may be because there is code on the main page that is referencing the aspx page using an AJAX call to display the content in a div container. Would this impact the jquery code from executing?

I basically included this as the bottom of the aspx page that has the table in it with the Gap values.


Open in new window

<script type="text/javascript">
setInterval(function() {                  
            $('#ost-GapRow tr td').each(function (i, item) {
                  if ($(item).text() > 0) {                        
                          $(item).attr('class', 'red');
                  }
            });
      }, 100);
</script>
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question