pilotvj
October 22, 2013, 11:56am
#1
Hello,
i created a Grid - Data comes from xml dataProcessor.
How can i change the Textcolor of a row after loading the data.
If the value off cell2 is “no” then the rowTextColor should be red.
I know the API Method : mygrid.setRowTextStyle
but how can I do this automaticly after loading the grid für all row`s…
Thx for your help.
Hello
I think you can choose…
a) Use your own eXcell style
http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:creating_editable_excells
b) You can set color in xml
http://www.dhtmlx.com/docs/products/docsExplorer/doc/dhtmlxxml/index.html
c)Use event “onXLE”
http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:event_onxle
and use something like:
var totalRow=grid.getRowsNum();//in smart rendering returns expected number of rows
for(i=1;i<=totalRow;i++)
{
if(grid.cells(i,0).getValue()=="no") grid.setRowColor(i, "red");
}
note: i guess this will be slow
d) Use forEachRow method
http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:api_method_dhtmlxgridobject_foreachrow
pilotvj
October 24, 2013, 7:59am
#3
Hello,
thank you for your answer.
I tried for “testing” this opionion:
mygrid.attachEvent(“onXLE”, function() {
var totalRow=mygrid.getRowsNum();
for(i=1;i<=totalRow;i++)
{
if(mygrid.cells(i,3).getValue() == “yes”) mygrid.setRowTextStyle(i, “color:red”);
}
});
But i doesn`t work - Chrome Console says:
Cannot read property ‘_childIndexes’ of null…
Any Idea?
Thx
sematik
October 24, 2013, 5:56pm
#4
Unfortunately the issue cannot be reproduced locally.
Please, make sure that you address to a existing row id.
pilotvj
October 28, 2013, 8:30am
#5
Hello - this works:
mygrid.attachEvent("onXLE", function(grid_obj,count) {
var totalRow=mygrid.getRowsNum();
for(i=0;i<=totalRow;i++){
rid = mygrid.getRowId(i);
if(typeof rid != 'undefined'){
if(mygrid.cells(rid,5).getValue() == "yes") mygrid.setRowTextStyle(rid, "color:blue");
if(mygrid.cells(rid,15).getValue() == "1") mygrid.cells(rid,0).setBgColor('Aquamarine');
}
}
});