I was implemented kendo Grid Hierarchy in my list page. but when i list child item without client template then auto increment id of each item showing properly but when i use clientTemplate property of kendo grid in child grid to show auto increment id then only auto increment id of parent item was showing. Example showing on bellow https://demos.telerik.com/kendo-ui/grid/hierarchy
@(Html.Kendo().Grid(Model.OrderList)
.Name(
"Grid"
)
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Width(
"50px"
).Sortable(
false
).Filterable(
false
).Title(
"<input type='checkbox' id='chkSelectAll' onchange='SelectAll();'/>"
).ClientTemplate(
"<input type='checkbox' id='orderselect_#=OrderID#' class='orderselect' value='#=OrderID#' onchange='chkOrUnchk(this)'/>"
);
})
.Resizable(r => r.Columns(
true
))
//.Reorderable(r => r.Columns(true))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple).Enabled(
true
))
.Events(events => events.Change(
"Grid_OnRowSelect"
).DataBound(
"OrderGrid_OnDataBound"
).ColumnReorder(
"Grid_OnColumnReorder"
))
.Pageable(settings => settings.PageSizes(
new
int
[] { 25, 50, 100, 500 }))
.Sortable()
.Scrollable(s => s.Virtual(
false
).Height(
"600px"
))
.Filterable()
.ClientDetailTemplateId(
"childOrders"
)
.DataSource(dataSource => dataSource
//.Server().Model(model => model.Id(p => p.OrderID))
.Ajax()
.PageSize(Model.DefaultOrderPageSize)
.Read(read => read.Action(
"ManageOrderLoadForGridAjax"
,
"Order"
).Data(
"OrderSearchParameter"
))
)
)
Child Grid
<script id=
"childOrders"
type=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid(
new
List<SMOrderNew>())
.Name(
"grid_#=OrderID#"
)
// template expression, to be evaluated in the master context
.Columns(columns =>
{
// *i want child order number but return parent order number using client template*
columns.Bound(p => p.OrderID).Width(
"50px"
).Sortable(
false
).Filterable(
false
).ClientTemplate(
"<input type='checkbox' id='orderselect_#=OrderID#' class='orderselect' value='#=OrderID#' onchange='chkOrUnchk(this)'/>"
);
columns.Bound(p => p.OrderNumber).Groupable(
false
).Width(
"200px"
).Template(@<text></text>).ClientTemplate(
"<a #if(DisplayDistribution){# class='OrderHover'#}# data-id='#= OrderID #' href='javascript:void(0);' style='float:left;' onclick='OpenOrderDetailsPopup(\"#= OrderID #\", 0);'> #=OrderNumber# </a>"
);
//columns.Bound(p => p.StoreName).Title("Store").Width(100).Template(@<text></text>).ClientTemplate("<div style='background:url(\"#=StoreImage_Icon#\") no-repeat left -2px; padding-left:20px;'>#=StoreName#</div>");
columns.Bound(p => p.BuyerUserID).Width(
"200px"
).Title(
"Buyer User ID"
).HtmlAttributes(
new
{ style =
"white-space: nowrap;"
});
})
.Events(events => events.Change(
"Grid_OnRowSelect"
).DataBound(
"OrderGrid_OnDataBound"
).ColumnReorder(
"Grid_OnColumnReorder"
))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(100)
.Read(read => read.Action(
"ManageChildOrderLoadForGridAjax"
,
"Order"
,
new
{ OrderId =
"#=OrderID#"
}))
)
//.ClientDetailTemplateId("attributeOption")
.Pageable()
.Sortable()
.ToClientTemplate()
)
</script>