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

Grid datasource option vs setDataSource method

3 Answers 1923 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 2
Warren asked on 18 Jun 2014, 06:46 PM
Hey guys,

Having an issue and wondering if I am doing something wrong. What I'm trying to achieve is initialize the grid on the page load and set the datasource at some other point (e.g. button click) using the setDataSource method but it won't load. Am I missing something or doing it wrong?

Working fine - Grid initialize using grid datasource option:
http://jsfiddle.net/dannycabrera/77Gbn/

Not working - Grid setDataSource method:
http://jsfiddle.net/dannycabrera/77Gbn/2/

Thanks for the help.

3 Answers, 1 is accepted

Sort by
0
Warren
Top achievements
Rank 2
answered on 18 Jun 2014, 06:50 PM
*Edit* - working links:

Working fine - Grid initialize using grid datasource option:
http://jsfiddle.net/dannycabrera/77Gbn/

Not working - Grid setDataSource method:
http://jsfiddle.net/dannycabrera/77Gbn/2/
0
Alexander Popov
Telerik team
answered on 20 Jun 2014, 03:26 PM
Hi Warren,

I would recommend passing a DataSource object to the setDataSource method. For example: 
var ds = new kendo.data.DataSource({
    data: [{"Brand":"Chevrolet","Model":"Corvette","Color":"Red","Doors": 2},
           {"Brand":"Ford","Model":"Mustang","Color":"Blue","Doors": 2}]
});
 
$("#grid").data("kendoGrid").setDataSource(ds);


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Warren
Top achievements
Rank 2
answered on 21 Jun 2014, 04:53 AM
Thanks Alexander, exactly what I needed. Working great now.
Tags
Grid
Asked by
Warren
Top achievements
Rank 2
Answers by
Warren
Top achievements
Rank 2
Alexander Popov
Telerik team
Share this question
or