addRow() in 5.0.2 version causing Uncaught TypeError

Hi Team,

We are facing one issue with DHTMLX grid in version 5.02. which is working fine with 4.1.3 version.

Below is the screen shot, first we are adding one column (BRAND) (Image to demonstrate the selection has been attached) . Add function we are calling here is

dhtmlxGridObj.addRow(selectedID, [(dhtmlxGridObj.getRowsNum() == 0 ? 1 : 0), displayText]);

After that trying to delete this column without changing any other options. Delete function we are calling here is

function removeGridRow() { if(dhtmlxGridObj.getRowsNum() > 0) { if(dhtmlxGridObj.getSelectedRowId() != null) { dhtmlxGridObj.deleteSelectedRows(); }else { Confirm(gridRowsDeleteAllMsg,function(){ dhtmlxGridObj.clearAll(); },function(){}); } } }

After that if we try to add any of the column from left side, it is not working and we are not able to add any of the columns. And below is the console error log while calling the add() function.
Uncaught TypeError: Cannot read property ‘_childIndexes’ of null
at window.(anonymous function).cells (localhost:…dhtmlx/dhtmlx.js:9:852793)
at eXcell_ra.setValue (localhost:…dhtmlx/dhtmlx.js:9:875286)
at window.(anonymous function)._fillRow (localhost:…dhtmlx/dhtmlx.js:9:839416)
at window.(anonymous function)._addRow (localhost:…dhtmlx/dhtmlx.js:9:850263)
at window.(anonymous function).addRow [as _addRowClassic] (localhost:…dhtmlx/dhtmlx.js:9:851260)
at window.(anonymous function).dhtmlXGridObject.addRow (localhost:…dhtmlx/dhtmlx.js:9:1120705)

It seems Issue is some where with dhtmlxGridObj.addRow() or dhtmlxGridObj.deleteSelectedRows() functions from 4.1.3 to 5.0.2 versions. Also on deleting rows using clearAll(), we are not facing this issue. Could Someone help on this.

Please, make sure that you have no duplicating ids in your grid. Also check that you have no id=“0”.

If the problem still occurs for you please, provide with a complete demo or share with a demo link, where the problem can be reconstructed.

hey @sematik, Please find attached the working sample of the defect.

Steps to replicate:

  1. Open index.html, click on Root1, select a child element, click on Add Row button. ( the child element gets added to the grid with default checkbox selected if it’s the first row).
  2. Add few more child elements from the tree to grid in similar fashion.
  3. Now select a row from the grid and click on Delete Row button, repeat the steps until you have deleted all the rows manually.
  4. Select some different child element ( not same as the element we added previously as the first row) and click on Add Row.

We are getting the following error.
Uncaught TypeError: Cannot read property ‘_childIndexes’ of null
at window.(anonymous function).cells (file:///C:/…/basic_grid/basic_grid/codebase/dhtmlx.js:9:833973)
at eXcell_ra.setValue (file:///C:/…/basic_grid/basic_grid/codebase/dhtmlx.js:9:856466)
at window.(anonymous function)._fillRow (file:///C:/…/basic_grid/basic_grid/codebase/dhtmlx.js:9:820596)
at window.(anonymous function)._addRow (file:///C:/…/basic_grid/basic_grid/codebase/dhtmlx.js:9:831443)
at window.(anonymous function).addRow (file:///C:/…/basic_grid/basic_grid/codebase/dhtmlx.js:9:832440)
at addBook (file:///C:/…/basic_grid/basic_grid/index.html:51:20)
at HTMLButtonElement.onclick (file:///C:/…/basic_grid/basic_grid/index.html:29:30)

PS: if you don’t select a row before clicking on the Delete Row button, all rows get deleted simultaneously as clearAll() method is called. In this case we are not facing the defect.
basic_grid.zip (516 KB)

The problem is confirmed. We’re working on a solution.

The problem is fixed. The solution will be included in the future version of the dhtmlxGrid.
If it is critical for you please, open ticket at support.dhtmlx.com so we can provide with the fixed dhtmlxgridcell.js file.