Clear Grid datasource Items

1 Answer 5439 Views
Grid
Chatra
Top achievements
Rank 1
Chatra asked on 15 Jul 2014, 10:39 PM
Hi,

I want to clear Grid data items but since grid is enabled for sorting and searching when any operation Sort/Search is performed the Data is getting back to grid.

 Can any one help how to tackle this situation.

I am clearing the data-source data items by  $("#Grid").data("kendoGrid").dataSource.data([]);

Thanks,
Chatrapathi chennam

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 17 Jul 2014, 11:29 AM
Hello Chatra,

You can use the Grid's setDataSource method and assign a new empty datasource instance.

http://docs.telerik.com/kendo-ui/api/web/grid#methods-setDataSource

var newDataSource = new kendo.data.DataSource({
  data: []
});

However, in this way you will lose all existing Grid dataSource settings. If you need to make the Grid work again (e.g. make remote data requests), you will have to assign a new DataSource instance with the correct settings.

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Chatra
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or