<script type="text/x-jsrender" id="customColumnTemplate">
<div style='padding-left:5px;'>{{if Approved}}<input type="checkbox" class="customCheckbox" checked>{{else}}<input type="checkbox" class="customCheckbox" />{{/if}}</div>
</script>
@(Html.EJ().TreeGrid("TreeGridContainer")
.Columns(co =>
{
//.. co.Field("Approved").HeaderText("Approved").IsTemplateColumn(true).TemplateID("customColumnTemplate").EditType(TreeGridEditingType.Boolean).Width(30).Add();
})
)
<script>
$("#TreeGridContainer").on("change", ".customCheckbox", function (e) {
var $tr = $(e.target).closest('tr'),
treeObj = $("#TreeGridContainer").data("ejTreeGrid"),
checkStatus = $(e.target).is(':checked'),
rowIndex = treeObj.getRows().index($tr),
record = treeObj.model.currentViewData && treeObj.model.currentViewData[rowIndex];
//to update all the record collection
record.Approved = record.item.Approved = checkStatus;
});
</script> |