Hi i am binding my kendo grid with DataTable and trying to display some columns as checkbox using clienttemplate. However every time i am trying i am getting error doing that.
Does anyone know how i can achieve this?
I have attached the mockup of image what im trying to achieve i.e. grid-mockup.jpg.
The error message i get is: Uncaught ReferenceError: ColumnName is not defined
Here is my Razor code:
@using Kendo.Mvc.UI
@model System.Data.DataTable
@(Html.Kendo().Grid<
dynamic
>()
.Name("Grid")
.Columns(columns =>
{
foreach (System.Data.DataColumn column in Model.Columns)
{
if (column.ColumnName != "SupplierNumber" && column.ColumnName != "CustomerItemNumber")
{
columns.Bound(column.ColumnName).ClientTemplate("<
input
type
=
'checkbox' disabled
#= ColumnName == 'True' ?
checked
=
'checked'
: '' # />");
}
else
{
columns.Bound(column.ColumnName);
}
}
columns.Command(cmd => cmd.Edit());
})
.Pageable()
.Sortable()
.Editable(ed => ed.Mode(GridEditMode.PopUp))
.Filterable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
var id = Model.PrimaryKey[0].ColumnName;
model.Id(id);
foreach (System.Data.DataColumn column in Model.Columns)
{
var field = model.Field(column.ColumnName, column.DataType);
if (column.ColumnName == id)
{
field.Editable(false);
}
}
})
.Read(read => read.Action("Read", "Home"))
.Update(update => update.Action("Update", "Home"))
)
)