Forum


06:40

09/03/2010

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
08:12

28/03/2010

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'});
}
}
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66