My goal is to make a grid where only the checkbox (IsActive
) is editable and it should be editable without having to press an edit button.
I would like for the checkbox to be bound to the model, instead of making a manual checkbox and then handle changes myself.
The result should look somewhat like this: http://demos.telerik.com/aspnet-mvc/razor/grid/headerfootertemplates
Model
public class MyModel
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsActive { get; set; }
}
View
Html.Telerik().Grid(Model)
.Name("grid")
.Columns(column =>
{
column.Bound(x => x.Id);
column.Bound(x => x.Name);
column.Bound(x => x.IsActive)
.HeaderTemplate(@<text>@Html.CheckBox("checkAll")</text>);
})
.EnableCustomBinding(true)
.DataBinding(dataBinding => dataBinding.Server().Select("Index", "Stuff"))
.Render();
Is it possible?
Using Template
seems like the only option.
I switched to Ajax binding so I'm using ClientTemplate
column.Bound(x => x.IsActive)
.ClientTemplate("<input type=\"checkbox\" name=\"checkedRecords\" value=\"<#= Id #>\" <#= IsActive ? \"checked='checked'\" : '' #> />")
.HeaderTemplate(@<text>@Html.CheckBox("checkAll")</text>);
Now I just need to figure out how bind a checkbox click to a command.Update()
.