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

Setting new datasource for editable grid not working

1 Answer 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcel
Top achievements
Rank 1
Marcel asked on 14 Feb 2013, 03:00 PM
Hello,

I have added an example of the problem, see:
http://jsbin.com/edamuj/427/edit

I have an editable grid and want to connect it with an editable datasource. This works if I create the grid with the datasouce available. However in my solution I am not sure when the js for the datasource is rendered but if it is rendered I register it in a kendo observable array. A function to set the the grids datasource is bound the change event of the observable array. After this function fires I would like the grid to show the data. Unfortunately this is not working. I simplified the problem and added it as an example. Can someone explain to me what I am doing wrong here?

Marcel

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 15 Feb 2013, 12:10 PM
Hello Marcel,

I'm afraid that the such assignment to the dataSource field will not yield correct results nor it is supported. In order to change the DataSource associated with the Grid widget, you should use the setDataSource method instead. This will ensure the correct event handlers are attached and the Grid widget is properly connected with the new DataSource instance.

$("#grid").data("kendoGrid").setDataSource(myDataSource);

Also I have notice that in the provided test page the retrieval of the Grid widget instance from the DOM element is not correct. Please take a look at this help article for details on how to get the widget instance.All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Marcel
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or