Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by simto on Jun 07, 2009 19:42
open dhtmlx forum
How do I set row color as data when initialize grid from json object


I try to set row color or text color differently as json data.

for example

I made this Json object that contains

value="{ id :'${inquiry.id}',
     userdata:{categoryId:'${inquiry.categoryId }',
ansIdForAnswer : '${inquiry.ansIdForAnswer}'                
},
data:['${checkvalue}','${inquiry.id}','${inquiry.title}','${inquiry.categoryName}','${inquiry.custId}',
     '${inquiry.custEmail}','${inquiry.unacptRegistDate}','${inquiry.registDate}','${inquiry.memberGradeName}' ]}"/>

I'd like to set text color red if inquiry.registDate is passed 24 hours from currentTime ,
set it blue if it is passed 12 hours from currentTime etc.

I found setRowTextStyle(row_id , style String) from your API Function Document.

but it can be used after initializing grid and loading the json data by checking whole data through another loop. isn't it?

is there a API or solution set the color while I load data?



Answer posted by dhxSupport on Jun 08, 2009 01:48
The best way to do that is to implement custom eXcell type. Please check this article http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=8995&ssr=yes&s=dynamic%20color%20change
Answer posted by Support on Jun 08, 2009 01:55
Also, you can try to use onRowCreated event

grid.attachEvent("onRowCreated",function(id){
            var vall = this.cells(id,6);
            if (some_check(vall))
                 this.setRowTextStyle(id ,"some styles here"); 
})