In Index.cshtml I have the following:
@{
Html.Telerik().Grid<hekomaseru.Models.testdbEntities1>("testtable")
.Name("grid1")
.Pageable()
.Sortable()
.Filterable()
.Groupable()
.Render();
}
And in HomeController.cs I do this:
public ActionResult Index()
{
List<int> abc = new List<int>() { 1, 2, 3, 4, 5 };
ViewData["testtable"] = abc;
return View();
}
For some reason though when everything loads up the grid is always empty (no records to display). Any ideas why it wouldn’t work?
I have other telerik stuff working (namely the drop down menus) so I don’t think it has anything to do specifically with that..
The grid needs to bind to a list of objects. A list of ints won’t work because they are value types. A list of strings will work like Lester said, but the only property is length. If you want a list of ints, you could add a class like this.
Then in the Controller.
The View
To make the grid more interesting, just add more properties to the Numbers class.