I am facing an issue with passing parameters to a Kendo Grid subgrid’s ClientTemplate. Specifically, I have a column DMSSerialNumber in the subgrid where I want to pass this value as part of a JavaScript function when an action is triggered from the template.
Here is the code for the main grid:
@(Html.Kendo().Grid<Asset360.App.Entities.Custom.Proc_GetSalesInvoiceModel>()
.Name("gridViewInvoice")
.ToolBar(e => e.Template(""))
.Columns(columns =>
{
columns.Bound(p => p.ContactName).Title("Customer Name").Filterable(true).Width(250);
columns.Bound(p => p.EmailAddress).Title("Email Address").Filterable(true).Width(250);
columns.Bound(p => p.Progress).Title("Progress").ClientTemplate("#if(Progress == 'Approved'){#<span class='label label-primary'>#=Progress#</span>#}else if(Progress == 'Pending'){#<span class='label label-danger'>#=Progress#</span>#}else{#<span class='label label-warning'>#=Progress#</span>#}#").Filterable(true).Width(150);
columns.Bound(p => p.Quantity).Title("Quantity").Filterable(true).Width(100);
columns.Bound(p => p.InvoiceDate).Title("Invoice Date").Format("{0:dd-MM-yyyy}").Filterable(true).Width(125);
columns.Bound(p => p.DueDate).Title("Due Date").Format("{0:dd-MM-yyyy}").Filterable(true).Width(125);
columns.Bound(p => p.Description).Title("Description").Filterable(true).Width(250);
columns.Bound(p => p.UnitAmount).Title("Unit Amount").Filterable(true).Width(100);
columns.Bound(p => p.Total).Title("Total").Filterable(true).Width(100);
columns.Bound(p => p.AccountCode).Title("Account Code").Filterable(true).Width(100);
columns.Bound(p => p.TaxType).Title("Tax Type").Filterable(true).Width(100);
columns.Bound(p => p.Currency).Title("Currency").Filterable(true).Width(100);
})
.ColumnMenu(columnmenus =>
{
columnmenus.Columns(false);
})
.HtmlAttributes(new { style = "height: 500px" })
.Scrollable(a => a.Height("auto"))
.ClientDetailTemplateId("rowChargesToBeBilledByAgNoDetailTemplate")
.DataSource(ds => ds
.Ajax()
.Read(read => read.Action("GetViewSalesInvoiceSummary", "Invoices").Data("a360.app.bills.filterBillingInvoiceManagement"))
.PageSize(PageSize.FirstOrDefault())
)
.Events(e => e.DataBound("a360.app.bills.onDataBound").ColumnHide("ilaas.app.common.showHideColumn").ColumnShow("ilaas.app.common.showHideColumn"))
.Pageable(page => page
.PageSizes(PageSize)
.Messages(msg => msg
.Display("{0} - {1} of {2:n0} items")
.Empty("No results found!")
)
)
.Filterable()
.Sortable(s => s.SortMode(GridSortMode.SingleColumn))
.Resizable(e => e.Columns(true))
.Selectable(selectable => selectable.Enabled(false))
.Reorderable(e => e.Columns(true))
)
And here’s the code for the subgrid where the issue occurs:
@(Html.Kendo().Grid<Asset360.App.Entities.Custom.Proc_GetXEROInvoiceModel>()
.Name("GridDetail")
.HtmlAttributes(new { @class = "sub-kendogrid-custome" })
.ToolBar(e => e.Template(""))
.Columns(columns =>
{
columns.Bound(p => p.ContactName).Title("Contact Name")
.ClientTemplate("<div class='btn-group grid-drop-box'>"
+ "<a class='asset-number'>#=ContactName #</a>"
+ "<a href='javascript:void(0)' class='btn-link dropdown-toggle ml-2' data-toggle='dropdown'>"
+ "<i class='fa fa-ellipsis-v'></i></a>"
+ "<ul class='dropdown-menu pull-left left-arrow' style='margin: 0px 0 0 25px;' role='menu'>"
+ "<li><a class='lnkColor sel-TradeIn' href='javascript:void(0);' data-toggle='modal' onclick='return a360.app.bills.DoNotProcessChargesToBilledDataSaved("#=DMSSerialNumber#","#= ContactName#","#= Quantity#", "#=Total#","DoNotProcess")'>Do Not Process</a></li>"
+ "</ul>"
+ "</div>")
.Filterable(false).Width(100);
columns.Bound(p => p.AgreementNumber).Title("Agreement Number").Filterable(false).Width(100);
columns.Bound(p => p.DMSSerialNumber).Title("DMSSerial Number").Filterable(false).Width(100);
columns.Bound(p => p.RentalStartDate).Title("Rental StartDate").Filterable(false).Width(100);
columns.Bound(p => p.RentalEndDate).Title("Rental EndDate").Filterable(false).Width(100);
columns.Bound(p => p.SupportFee).Title("Support Fee ($)").Filterable(false).Width(130);
columns.Bound(p => p.RentalFee).Title("Rental Fee ($)").Filterable(false).Width(130);
columns.Bound(p => p.SimCardFee).Title("SimCard Fee ($)").Filterable(false).Width(130);
columns.Bound(p => p.TotalMonthlyFee).Title("Total Monthly Fee ($)").Filterable(false).Width(150);
columns.Bound(p => p.Total).Title("Total").Filterable(false).Width(130);
})
.ColumnMenu(columnmenus =>
{
columnmenus.Columns(false);
})
.DataSource(ds => ds
.Ajax()
.Read(read => read.Action("GetChargesToBeBilledDetails", "Bills")
.Data("a360.app.bills.filterInvoiceNumberDetails('#=InvoiceNumber#','#=ContactName#')"))
.PageSize(PageSize.FirstOrDefault())
.Model(model =>{
model.Id(p => p.DMSSerialNumber);
model.Field(p => p.DMSSerialNumber);
})
)
.Events(e => e.DataBound("a360.app.bills.onDataBound"))
.Pageable(page=> page.PageSizes(PageSize)
.Messages(msg => msg
.Display("{0} - {1} of {2:n0} items")
.Empty("No results found!"))
)
.ToClientTemplate()
)