Hi Kendo Team,
I have a grid with multiple child grids. I'm having troubles trying to do checkbox selection for the grid and its child grids with the requirements: selecting one record from parent grid should select all records of its child grid and select one record of the child grid should select its parent record accordingly.
The main grid:
The child grid template:
Both grid models:
Also I'm having troubles extracting the property using
and
Which throws "Invalid Template" error. Is it because the property is not of the model but of the wrapped class? But then the following works just fine:
Thank you and regards,
Michael Pham.
I have a grid with multiple child grids. I'm having troubles trying to do checkbox selection for the grid and its child grids with the requirements: selecting one record from parent grid should select all records of its child grid and select one record of the child grid should select its parent record accordingly.
The main grid:
@(Html.Kendo().Grid<PendDetailRecordDTO>() .Name("pendDetailRecord_grid") .Columns(columns => { columns.Bound(c => c.DetailRecord.ID).HeaderTemplate(@<input type="checkbox" id="selectAll" />) .ClientTemplate(@" # if (StatusText=='Failed') { # <input type=""checkbox"" class=""app_select"" data-refid='#: DetailRecord.ID #'/> # } # ").Sortable(false).Width(20); columns.Bound(c => c.DetailRecord.StorageLoc).Title("Storage Location").Width(105); columns.Bound(c => c.StorageLocationText).Title("Store Name").Sortable(false).Width(105); columns.Bound(c => c.DetailRecord.MainMaterialNo).Title("Main Stockcode").Sortable(true).Width(95); columns.Bound(c => c.DetailRecord.Qty).Title("Qty").Sortable(true).Width(35); columns.Bound(c => c.DetailRecord.ErrMsg).Title("Error Message").Sortable(false); columns.Bound(c => c.StatusText).Title("Status").Sortable(false).Width(55); columns.Bound(c => c.DocNo).Title("Doc No").Sortable(false).Width(75); columns.Bound(c => c.FileName).Title("File Name").Sortable(true).Width(250); } ) .Pageable() .Sortable(sort => sort.AllowUnsort(false)) .Scrollable(scr => scr.Height(400)) .Resizable(resizable => resizable.Columns(true)) .DataSource(dataSource => dataSource.Ajax() .PageSize(20) .Batch(true) .ServerOperation(true) .Read(read => read.Action("GetPendDetailRecord", "Inventory", new { stockCode = Model.StockCode, storeID = Model.StoreID, fromDate = Model.FromDate, toDate = Model.ToDate, status = (Model.Status == null) ? string.Empty : string.Join(",", Model.Status), error = Model.Error})) ) .ClientDetailTemplateId("DetailSectionTemplate") )The child grid template:
@(Html.Kendo().Grid<PendDetailSectionDTO>() .Name("pendDetailSectionGrid_\\#=DetailSection.ID\\#") .Columns(columns => { columns.Bound(c => c.DetailSection.ID).HeaderTemplate(@<input type="checkbox" id="selectAllSection" />) .ClientTemplate("\\# if (StatusText=='Failed') { \\# <input type='checkbox' class='app_select_Section' data-refid='\\#: DetailSection.ID \\#'/> \\# } \\#") .Sortable(false).Width(20); columns.Bound(c => c.DetailSection.ID).Title("ID"); columns.Bound(c => c.DetailSection.MaterialNo).Title("Stockcode").Width(90); columns.Bound(c => c.DetailSection.UID).Title("UID").Sortable(false).ClientTemplate("\\#if (DetailSection.UID!=null&&DetailSection.UID!='') {\\#<a href='" + @Url.Content("~/Inventory/InventoryDetail") + "?SerialNo=\\#=DetailSection.UID\\#'>\\#=DetailSection.UID\\#</a>\\#}\\#"); columns.Bound(c => c.DetailSection.ManufacturePartNo).Title("Part No").Width(90); columns.Bound(c => c.StatusText).Title("Status").Width(55); columns.Bound(c => c.DetailSection.ErrMsg).Title("Error Message"); } ) .Pageable() .DataSource(source => source.Ajax() .PageSize(5) .ServerOperation(false) .Read(read => read.Action("GetPendDetailSection", "Inventory", new { detailRecordId = "#=DetailRecord.ID#" })) )Both grid models:
public class PendDetailRecordDTO{ public string StatusText { get; set; } public string StorageLocationText { get; set; } public string DocNo { get; set; } public string FileName { get; set; } public SAP_DetailRecord_STG DetailRecord { get; set; } public PendDetailRecordDTO(SAP_DetailRecord_STG detailRecord) { DetailRecord = detailRecord; }}public class PendDetailSectionDTO{ public string StatusText { get; set; } public SAP_DetailSection_STG DetailSection { get; set; } public PendDetailSectionDTO(SAP_DetailSection_STG detailSection) { DetailSection = detailSection; }}Also I'm having troubles extracting the property using
.Name("pendDetailSectionGrid_\\#=DetailSection.ID\\#")data-refid='\\#: DetailSection.ID \\#'Which throws "Invalid Template" error. Is it because the property is not of the model but of the wrapped class? But then the following works just fine:
.ClientTemplate("\\#if (DetailSection.UID!=null&&DetailSection.UID!='') {\\#<a href='" + @Url.Content("~/Inventory/InventoryDetail") + "?SerialNo=\\#=DetailSection.UID\\#'>\\#=DetailSection.UID\\#</a>\\#}\\#")Thank you and regards,
Michael Pham.
