In my case, the main grid retrieves its data via an Ajax datasource
@(Html.Kendo().Grid<ViewModels.IconViewModel>() .Name("Icons") .Columns(columns => { ... }) .Pageable() .Scrollable(s => s.Height("auto")) .Navigatable() .Selectable(s => s.Mode(GridSelectionMode.Single)) .DataSource(dataSource => dataSource .Ajax() .PageSize((int)Model.RowsPerPage) .Read(read => read.Action("GetIcons", "API") .Type(HttpVerbs.Get))) .Events(e => e.DetailInit("detailInit")) .ClientDetailTemplateId("inner-grid-template") .AutoBind(true))
and the detail template is defined as
<script id="inner-grid-template" type="text/kendo-tmpl">@(Html.Kendo().Grid<ViewModels.IconReferenceViewModel>() .Name("IconReferences_#=Id#") .Columns(columns => { columns.Bound(o => o.ClassName).Filterable(false); columns.Bound(o => o.SubclassName).Filterable(false); }) .ToClientTemplate() )</script>
In the detailInit event, the data source of the detail grid is set to a property of the model. This property holds an array of items.
function detailInit(e) { var grid = $("#IconReferences_" + e.data.Id).data("kendoGrid"); var data = e.data.References; grid.dataSource.data(data);}
So far so good. The data is shown in the grid as intended. But I want the detailed grid to be pageable. I played around with:
- Setting .Pageable() in the detail template
- Adding a datasource in the detail template in order to set the pagesize (Ajax/Custom?)
- Setting grid.dataSource.pageSize (and other properties like serverPageable) in the detailInit() event.
This usually resulted in a brief flicker of the complete detail list or the page reloading or the complete list with a paging control (showing 1-10 of 20, but showing the complete list; using the paging control refreshed the main grid).
So what is the correct way of getting this done?
