Hi There,
I have a situation where I will have to do many same pages with the same Grid columns and functionality, but it will have a bit different dataSource I will have to read from the backend controller. Is there a way I can template the Grid itself and reuse it but be able to switch the dataSource?
For example.
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>() .Name("grid") .Columns(columns => { columns.Bound(c => c.ContactName).ClientTemplate( @"<div class='customer-photo' style='background-image: url(../content/web/Customers/#:data.CustomerID#.jpg);'></div> <div class='customer-name'>#: ContactName #</div>") .Width(240); columns.Bound(c => c.ContactTitle); columns.Bound(c => c.CompanyName); columns.Bound(c => c.Country).Width(150); }) .HtmlAttributes(new { style = "height: 550px;" }) .Scrollable() .Groupable() .Sortable() .Pageable(pageable => pageable .Refresh(true) .PageSizes(true) .ButtonCount(5)) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Customers_Read", "Grid")) .PageSize(20) ))
I want the
.DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Customers_Read", "Grid")) .PageSize(20))
Customers_Read to be switched to OldCustomers_Read
or NewCustomers_Read
or CustomersEtc_Read
But I don't want to copy everything of the Grid over and over.
How can I do this?
Thank You
