The grid is setup and works perfectly and has detail rows associated. A button is to live on the detail section and do the same thing as the little triangle that collapses the row. Looking through the forums, I see the following code should work, but it doesn't close the record. Any help will be greatly appreciated.
<script>
var
toggleDetail =
function
(e) {
var
grid = $(
"#childGrid"
).data(
"kendoGrid"
);
var
parentRow = grid.wrapper.closest(
"tr"
).prev();
grid.collapseGroup(parentRow);
};
$(document).ready(
function
() {
$(document).on(
"click"
,
"#toggleDetail"
, toggleDetail);
});
</script>
@(Html.Kendo().Grid<Elsis.Application.Model.Child.ChildListModel>()
.Name("childGrid")
.Columns(columns =>
{
columns.Bound(c => c.Name).Width(120);
columns.Bound(c => c.Age).Width(80);
columns.Bound(c => c.Teachers).Width(200);
columns.Bound(c => c.Schedule).Width(200);
})
.HtmlAttributes(new { style = "height: 550px;", @class = "lcesGrid" })
.Scrollable()
.Sortable()
.ClientDetailTemplateId("childDetailTemplate")
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ChildList_Read", "ChildList"))
.PageSize(20)
)
)
<script id="childDetailTemplate" type="text/kendo-tmpl">
<div>
<div style="float: left; width:100px;">
<div>Picture</div>
<div>Full Bio</div>
</div>
<div style="float: left;width: 800px;">
<div style="float: left;width: 800px;">
<div style="float: left;width: 225px;">
<span id="name">#= Name #</span>
<span id="childId">(#= ChildId #)</span>
</div>
<div style="float: left; width: 100px;">
<span id="age">#= Age #</span>
</div>
<div style="float: left; width: 100px;">
<button id="toggleDetail" class="toggleDetail">Close Button</button>
</div>
</div>
</div>
</div>
</script>