Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by abrauer on Sep 12, 2008 04:31
open dhtmlx forum
dhtmlxGrid forEachRow ignores rows with id=0

Hi,

when I have a row in grid with row id=0, the method
forEachRow will ignore it! This seems to be a bug.
Or is there a reason for this behaviour?


Answer posted by Support on Sep 12, 2008 05:33
In case of treeGrid the ID == 0 reserved for virtual root item. 
In case of plain grid - forEachRow must include such row in itteration. 
In common case it strongly not recommended to use IDs which can be treated as logical false - 0,null,undefined,NaN,false

If usage of 0 as ID is principial requirement in your case, and problem still occurs for you - please provide any kind of sample where issue can be reconstructed. 
Attachments (1)
Answer posted by abrauer on Sep 12, 2008 06:38
I attached an example that is based on
dhtmlxGrid\samples\initialization_loading\init_grid.html

I am using 0 as id since this is perfectly fine to do this in Java. And even in dhtmlxGrid the first colunm has index 0.
OK, I do understand the difference of id and index ... but why not?
Attachments (1)
Answer posted by Support on Sep 12, 2008 07:21
Javascript is dynamic language, it has not strict data types, so 0 and null and undefined - may be treated as equal values, which may cause issue.

If you will use 
    mygrid.addRow("0",'Value A1,Value B1'); //quotes added, ID set as string 
in your js code, all will work correctly