I'm trying to clear out my grid by setting the datasource to be empty. However, from what I've tried so far, I have issues when trying to initially set the datasource to empty, or when I try to add data back to my grid. It appears that you have to additionally set the "dataSourceType" to 'empty', but this presents other problems...
If I set the dataSourceType to empty:
$myGrid.igGrid('option', 'dataSourceType', 'empty');
$myGrid.igGrid('option', 'dataSource', []);
$myGrid.igGrid('databind');
This clears out my grid, but then, I use the addRow method to add rows back to this grid...
$myGrid.igGrid('addRow', {'employeeId', 5});
...and the dataSource of $myGrid is an empty array.
$myGrid.igGrid('options', 'dataSource') // empty array
I've tried setting the grid's datasource back to json before adding the row:
$myGrid.igGrid('option', 'dataSourceType', 'json');
...but still, the grid's dataSource is empty. Its like the rows are visually added, but the dataSource isn't updated.
Hello JoshNoe ,
Thank you for posting in our forum.
Have you tried calling the “commit” method of the grid?
Generally when you add a new row it may not be directly added to the grid’s data source if the autoCommit option of the grid is set to false.
Once you call the commit method all of the pending changes will be applied to the client data source.
Let me know if that helps.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://ko.infragistics.com/support
Hi Maya. Yes, autocommit is set to true, and I've tried calling the commit method manually. Neither make any difference. It appears that calling addRow, even with autocommit = true, does not add anything new to the dataSource of the grid, it only updates the display. Here's a simple example:
http://www.joshnoe.com/IgGridAddRow.html
Click the "Show Data" button at the bottom, and you'll see the current grid data. Then, click "Add Row", and a row will be added, and commit is called (autocommit is also set to true, so the commit call is redundant anyway). Next, click the "Show Data" button again. You'll see that the data was not added.