jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Jqxgrid row Background Problem
This topic contains 1 reply, has 2 voices, and was last updated by Vladimir 9 years, 8 months ago.
-
Author
-
Hi Peter,
I am using Jqxgrid to show some data.
I am setting the background color for the rows in specific column.
Here is my code,basically I am looping through my data and based on some conditions i decide the row color of specific column.Now my problem is if i apply filter to my jqxgrid data , row coloring does not work properly
Thanks
var cellclass = function (row, columnfield, value)
{var oldValue=””;
if (row == “0”) {
oldValue=value;
colorValue=’red’;
return colorValue;
}
else
{var data = $(‘#new_grid_data2’).jqxGrid(‘getrowdata’, row – 1);
var valueOfPrevious=data.ips;var currValue=value.substr(0,value.lastIndexOf(“.”)+1);
var previousValu=valueOfPrevious.substr(0,valueOfPrevious.lastIndexOf(“.”)+1);
if (currValue==previousValu)
{
if(colorValue==”red”)
{return ‘red’;
}else {
colorValue=””;
return ”;}
}
else {
if(colorValue==””)
{
colorValue=”red”;}else {
colorValue=””;}
return colorValue;
}
}if (value < 20) {
return ‘red’;
}
else if (value >= 20 && value < 50) {
return ‘yellow’;
}
else return ‘green’;
}Hello jumpstart,
Your logic relies on comparison relating to the previous row from the original unsorted and unfiltered data (due to the fact it is based on row id).
So I guess that sorting/filtering would not change that logic in any way and it will keep same formatting for the same row.
If you would like to get the visible rows information and use them as reference points, you should get them fromgetrows
orgetdisplayrows
and cycle through them to get the relevant row ID for your evaluation.Best Regards,
VladimirjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.