I'm trying to use a Kendo grid for the first time: Here's the code for the grid:
@model IEnumerable<SustIMS.Models.ModelTest>
<div id="clientsDb">
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.Genre).Width(140);
columns.Bound(c => c.Title).Width(190);
columns.Bound(c => c.ReleaseDate);
columns.Bound(c => c.Price).Width(110);
})
.HtmlAttributes(new { style = "height: 90%;" })
.Scrollable()
.Groupable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Read", "MasterDataController"))
)
)
</div>
<style scoped>
#clientsDb {
width: 95%;
height: 95%;
margin: 20px auto 0;
padding: 50px 4px 0 4px;
background: url('@Url.Content("~/content/web/grid/clientsDb.png")') no-repeat 0 0;
}
</style>
This displays the grid without any data in it. I've created a test model and am trying to add data like this in the controller:
public void Read()
{
ModelTest mt = new ModelTest();
mt.Title = "This is the title";
mt.Price = 10.5m;
}
This doesn't show any data in the grid. How can I pass data into it?
And does it have to come from a model or can it be added in a custom way?