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

IEnumerable datasource from C# code

3 Answers 646 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 28 Feb 2012, 03:59 PM
In my server side code I fetch the data to be displayed in the grid and it's returned as an IEnumerable. Can I use this as a datasource and if so how would I do this server side?

3 Answers, 1 is accepted

Sort by
0
Captain Awesome
Top achievements
Rank 2
answered on 02 Mar 2012, 06:18 AM
The KendoUI Grid is not bound to a Model. You have to bind it to JSON or ODATA client side. I just uploaded a sample to the Kendo Code Library showing how to do this in MVC.

I load an IEnumerable object up and return it as JSON:

return Json(person, JsonRequestBehavior.AllowGet);

Kendo example can be found here:
http://demos.kendoui.com/web/grid/remote-data.html

0
Justin
Top achievements
Rank 1
answered on 02 Mar 2012, 03:54 PM
I actually found the answer to this in one of the Telerik videos. You can simply pass it in as a javascript array.

Video:
http://www.youtube.com/watch?v=gVu79Sh6Lpg&feature=player_embedded

	dataSource:
	{
		data: sessions,
		serverSorting: true
	}

0
Scott
Top achievements
Rank 1
answered on 22 Mar 2014, 03:40 PM
Does the dataSource have to be an IEnumerable, or can I bind to a single entity?
Tags
Grid
Asked by
Justin
Top achievements
Rank 1
Answers by
Captain Awesome
Top achievements
Rank 2
Justin
Top achievements
Rank 1
Scott
Top achievements
Rank 1
Share this question
or