This is a migrated thread and some comments may be shown as answers.

Clear kendo odata grid

2 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Andrey asked on 07 Sep 2017, 01:09 PM

I'm looking for a way to clear my kendo grid which is using remote odata service. I know that I can call dataSource.data([]) when I'm using local data (i.e. setting dataSource.data config property), but I can't understand how to do the same thing using remote data (i.e. using data.transport). Any suggestions?

The only way I've found is to conditionally call options.success({empty odata response object}) in your transport callback. But the problem is that such empty object contains @odata.context property which is dynamically generated on the service side and I'm not sure where it is used by kendo or it is'nt.

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 Sep 2017, 05:51 AM
Hello Andrey,

Apologies for the delayed response, we were at very low capacity yesterday.

In general, setting conditionally an empty result in the success callback is probably the best approach in this scenario.

The dataSource.data([]) can still be used, as it is working as expected when the Grid is bound to remote data. Only when the server operations are used, the Grid will make a new request for every operation, and the data has to be cleared after every operation if needed.

If the used conditions used to determine if the data will be empty are available when the request is made, I can suggest also, using the logic on the requestStart event. If the Grid has to be empty, prevent the request and set the dataSource data to an empty array. This will also prevent unnecessary request to the server:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events-requestStart

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Andrey
Top achievements
Rank 1
answered on 14 Sep 2017, 01:04 PM
Thanks for response!
Tags
Grid
Asked by
Andrey
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Andrey
Top achievements
Rank 1
Share this question
or