Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1845
"Clear out" grid using datasource without side-effects
posted

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');

$myGrid.igGrid('addRow', {'employeeId', 5});

...but still, the grid's dataSource is empty.  Its like the rows are visually added, but the dataSource isn't updated.