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?





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.

1221224042.zip (84.8 KB)

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?

forEachRowTest.html.zip (793 Bytes)

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