Your documentation seems to state that this is possible, but grid.parse() clears existing row data. Using grid.addRow() is useless since it doesn’t support cell attributes or row userdata.
Is there a way to use grid.parse() to add new rows to loaded grids?
We use grid.parse(jsonObj,“json”) to load our grids rather than using a URL source.
We have done more testing and found that when trying to add a row to an existing grid, the ‘total_count’ and ‘pos’ attributes in the top-level JSON obj must be omitted. Including these attributes erases the existing rows (we do not use Smart Rendering).
However, the new added row is still not being inserted into the grid. No JavaScript errors are being thrown.
We tried issuing Start/StopFastOperations calls around the grid.parse() but that did not work.
Is there some other way to force a grid refresh and display the added row (assuming it is actually being added to the grid data structure)?
The grid.parse(jsonObj,“json”) definitely does NOT add the row to the grid. Issuing grid.doesRowExist(newRowId) immediately after the parse() returns false. We confirmed that the JSON object is correctly formed, with a unique ID. The JSON object is created by the same routines that load the grid with the initial array of JSON row objects, which works perfectly.
We really need this functionality to add rows. Any ideas?
The ‘pos’ attribute in the top-level JSON object must be set to the current row count, as in:
jsonObj.pos = theGrid.getRowsNum(); // Offset MUST be set to end of current row buffer
The ‘total_count’ attribute should be omitted, or set to 0. Unless these two parameters are set correctly, the parse() function will either reset the grid or fail to add the row without any indication.
With the correct parameters grid.parse() will add the new row (or multiple new rows) to the grid, complete with userdata and attributes, which is far more useful than addRow();
I strongly suggest you update your documentation to include this rather important information. We wasted many hours on this…
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan