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.

Parents
  • 29417
    Offline posted

    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://es.infragistics.com/support

     

Reply Children