Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Setting table cell style based on data values - How?
09/03/2010
06:40
Avatar
patrickj
New Member
Members
Forum Posts: 1
Member Since:
09/03/2010
sp_UserOfflineSmall Offline

newbie qn - not sure if this is the correct section for this type of query:

I need to display data in a grid and set the cell background color based on the the underlying data values - e.g. late payment dates are red for 90 days; orange for 180 days etc).  I need to do this at the cell level, not the row level as there can be several cells on the same row with a different status. 

I've thought about assigning additional adjacent hidden columns containing the style name on the server (invoking business rules to set the value) - then massaging the corresponding cell's style accordingly - but am not sure if/how that would work. Are there any examples of this available?

TIA,

Patrick

28/03/2010
08:12
Avatar
grantdd
New Member
Members
Forum Posts: 1
Member Since:
28/03/2010
sp_UserOfflineSmall Offline

I use afterInsertRow option for any row or cell manipulation.  Here's a quick example using the setCell method:

afterInsertRow : function(rowid, rowdata, rowelem)

{

      if (rowdata.columnXcell == desiredData)

      {

           // Add a class to the cell.  You could also pass something like this: {'background-color':'red'}.

          // Note the empty quotes in the setCell options--pass this if you want to leave the value of the cell unchanged

           $('#gridID').jqGrid('setCell',  rowid, 'colModelIndex', '', 'ClassName');

          // Or to change the entire row:

          $('#'+rowid).css({'background-color':'green'});

      }

}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
61 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information