Question

From a grid I can get the data source using:

var ds = $(#mygrid).data("kendoGrid").dataSource;

or from a listview:

var ds = $(#mylist).data("kendoListView").dataSource;

But how do I get it if I do not know if its a grid or listview (or scheduler)?

For example:

// Refresh data for any dataSource based control:
$(#myControl).data("???").dataSource.read();
Was it helpful?

Solution

You can get the widget of an object like this:

var control = kendo.widgetInstance($('#myControl'), kendo.ui);

Then you could check if there is a dataSource, and do something with it:

if(control.dataSource) {
    control.dataSource.read();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top