I need to clear a hierarchical grid after user click on Save button, if everything is ok then the user should be able to reuse the same grid to enter new data. How to do that?
Hello Luis Ledesma,
Thank you for posting to our forums!
Why do you need to clear out the rows in the grid? Are you using the grid as a type of input form? Our grids are designed to display the data they are bound to. If you have the data in the igGrid's datasource it will continue to display the new data the user entered. You would need to either remove the data from the datasource or bind the grid to a new, empty datasource.
Please see this jsFiddle that demonstrates how you could assign a new datasource to an igGrid.
If you have any further questions or concerns with this, please let me know.
Thanks Michael. Yes, I am using the grid to let user enter data. I found a way to clear grid's data and reuse the grid after posting:
$('#MyGrid').igGrid('commit'); var ds = $("#MyGrid").igGrid("option", "dataSource"); ds.Records.splice(0, ds.Records.length); $("#MyGrid").igGrid('option', 'dataSource', ds); $("#MyGrid").igGrid("dataBind");
But, is there a better way?
Well, maybe there is no better way :(