error adding row in subgrid by contect menu in maingrid

hi

the function “addRow” the following code throws the error “Error: this.obj.firstChild is null’



code snippet:



switch (menuitemId) {

        case “newContactAddress”:

            var data=memberGrid.contextID.split(”_");

            memberGrid.cellById(data[0],0).open();

            var mysubgrid = memberGrid.cellById(data[0],0).getSubGrid();

                subGridDp.setUpdateMode(“off”);

                mysubgrid.addRow(“newAddressRow”,[1,null,null,null,null,null,150,null,null,null,null,null]);

                mysubgrid.setUserData(“newAddressRow”,“stamm_ID”,memberGrid.getUserData(data[0],“stamm_ID”));

                subGridDp.sendData();

                subGridDp.setUpdateMode(“cell”);

            return true;

        break;



this happens only when i add a new row to the subgrid by clicking a topic from contextual menu from the first row in maingrid (memberGrid). else it works like a charm (e.g. clicking contextual menu in second row in maingrid).



the error is made in dhtmlxGrid/codebase/dhtmlxgrid.js, line 853

any suggestions? thx

Unfortunately we cannot reproduce this issue locally. Please provide us complete example where we can reproduce it. Content of complete example you can find here dhtmlx.com/docs/support/what … d_demo.htm

I found out why this happend:
mysubgrid.addRow(“newAddressRow”,[1,null,null,null,null,null,150,null,null,null,null,null]);

only works, if
memberGrid.cellById(data[0],0).open();
has finished!

Since the subgrid is loaded by dynamic xml it takes too long to open the subgrid and the addRow()-functon is called before the subgrid has built the firstChild-Object.
I solved it with adding a little alert-statement which enables the grid’s open()-process to finish BEFORE the subgrid’s addRow()-function is called.
It’s a nasty work around. Would be cool to have some listener on the grid’s open()-function which runs code only, if subgrid-cell is fully opened.

Would be cool to have some listener on the grid’s open()-function which runs code only, if subgrid-cell is fully opened.
To handler if sub grid was loaded you can use onSubGridLoaded event dhtmlx.com/dhxdocs/doku.php?id=d … _to_events