I'm implementing a hierarchical grid. it's all working well except if the parent row's ViewModel doesn't have any child items, it still renders a grid with no rows for the detail template. This is the behavior I would expect, but not the behavior I want. If there are no child items, I want to not render a detail template and also not display the expand icon for that row. Here is a case where the same thing was requested for Kendo for Angular. And below is an excerpt of my view:
01.@(Html.Kendo().Grid<PmtHistAccountPaymentVM>(Model.PaymentHistory)02. .Name(gridName)03. .Columns(columns =>04. {05. columns.Bound(c => c.PaymentDate).Title("Date").Format("{0:d}");06. columns.Bound(c => c.PaymentAmount).Format("{0:C}").Title("Amount");07. })08. .ClientDetailTemplateId(gridID + "-accountTransGridTemplate")09. .NoRecords("No Payments")10. .DataSource(dataSource => dataSource11. .Ajax()12. .Model(model => { model.Id(p => p.ID); })13. .PageSize(15)14. .ServerOperation(true)15. .Read(read => read.Action("PaymentHistory_Read", "CustomerAccounts").Data("function(){ ... }"))16. )17. .Events(e => e.DetailInit("crm.accounts_pmthist.grid_initDetailGrid"))18. .Deferred()19.)20.<script type="text/x-kendo-temp" id="@gridID-accountTransGridTemplate">21. #if(TransactionPayments && TransactionPayments.length > 0){#22. @(Html.Kendo().Grid<PmtHistTransactionPaymentVM>()23. .Name(gridName+"#=ID#")24. .Columns(cols =>25. {26. cols.Bound(p => p.AccountTransactionProductName).Title("Description");27. cols.Bound(p => p.CostPaid).Format("{0:c}");28. cols.Bound(p => p.TaxPaid).Format("{0:c}");29. cols.Bound(p => p.PaymentAmount).Format("{0:c}");30. })31. //.Sortable()32. //.Filterable()33. .AutoBind(false)34. .DataSource(ds => ds.Ajax().ServerOperation(false))35. .ToClientTemplate()36. )37. #}#38.</script>
As you can see, on line 21, I attempted to add a conditional statement. This seems to have eliminated the detail template successfully but the expand icon still shows on the parent row and creates an error in the DetailInit event handler. I decided I'd better ask if I'm on the right track or if something better is available to accomplish this?
