I have a grid with a number of columns. 2 of the columns are Invoice Val and Receipt Val. I am setting the background colour of the Receipt Val as follows:
1 To red if Receipt Val is non-zero AND it’s not equal to Invoice Val.
2 To green if Receipt Val is equal to Invoice Val
3 No background colour if Receipt Val equals zero.
When the grid is first loaded the initial rows bieng displays show the correct background colour. However all rows that are not within the initial display are not being set. So when a user scrolls down then all rows that were previously not visible do not have any background colour applied.
This behavior appears due to the smart rendering or paging mode in your grid.
As the the grid data renders not completely and the setCellTextStyle() method can’t be applied to the not-rendered rows.
You need to create a custom exCell type which will change the color of your cell accordingly to it’s value.
Here you can find a detailed tutorial with examples: docs.dhtmlx.com/doku.php?id=dhtm … l_creation
Thanks very much for your quick response. I am trying to create a custom eXcell as follows:
function eXcell_rec(cell)
{
this.base = eXcell_link;
this.base(cell);
this.cell.style['background-color','#BDFCC9'];
eXcell_rec.prototype = new eXcell_link;
}
However in dhtmlxgrid_excell_link I’m getting an error saying that cell is undefined. When I look at the code in the link that you gave me for the custom cell creation tutorial it is different to the example link code.
Please remember that I’m using ver 3.0 Professional Full suite.
Please can you tell me what I’m doing wrong with my code?
Also within the function I need to get the row id for the relevant cell to get other values from the grid. Please can you tell me how I can get access to the row id within the function.
I finally got a chance to try out your suggestion and it worked brilliantly. Many thanks for that.
However I now have another issue. My full requirement is to change the backgroundColor of the cell depending on comparing the value in the cell with another value in the same row. I therefore need to know how I can acccess the rowid of the cell in question please. Basically I have an invoice column and a receipts column. If the receipts value is non zero and equal to invoice value then I set receipts backgroundColor to green otherwise to red. If receipts value is zero I leave the backgroundColor white. So for that I need to have the row id.
function eXcell_rec(cell)
{
this.base = eXcell_link;
this.base(cell);
rid = this.cell.parentNode.idd;
…
Please, try to make the rid a local variable but not a global.
function eXcell_rec(cell)
{
this.base = eXcell_link;
this.base(cell);
var rid = this.cell.parentNode.idd;
…
Unfortunately the issue cannot be reproduced locally.
If the problem still occurs for you, please, provide with a complete demo, where it can be reconstructed.
Here you can find a tutorial about creating a complete demo: docs.dhtmlx.com/doku.php?id=othe … leted_demo
At the menu under Test Options there is only 1 option: View Invoices Test.
When you run that you will get a window in which the grid appears and after the data is loaded but before it gets displayed you get the ‘too much recursion’ error.
Hope this helps. If you need any further info then please let me know.