0
votes

I'm using checkbox in Telerik Grid. following is my code

@(Html.Telerik().Grid<ProductModel>(Model.Products.Data)
                    .Name("products-grid")
                    .Columns(columns =>
                    {
                        columns.Bound(x => x.Id)
                        .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= Id #>' />")
                        .Title("")
                        .Width(36)
                        .HtmlAttributes(new { style = "text-align:center" });

                        columns.Bound(x => x.Id);
                        columns.Bound(x => x.Name);
                        columns.Bound(x => x.Published)
                            .Width(100)
                            .Template(x => x.Published.ToString().ToLower())
                            .Centered();

                    })
                    .Pageable(settings => settings.Total(Model.Products.Total).PageSize(gridPageSize).Position(GridPagerPosition.Both))
                    .DataBinding(dataBinding => dataBinding.Ajax().Select("ProductReport", "Product"))
                    .ClientEvents(events => events.OnDataBinding("onDataBinding"))
                    .EnableCustomBinding(true)
                    )

I just see Id's in the checkbox column instead of checkboxes. Can anyone tell me what is wrong with my code ??

i checked this question and a few other but they dint answer my problem..

1

1 Answers

0
votes

The problem is with your code definition, you just defined template in ajax call mode (with clientTemplate method):

.ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= Id #>' />")

But you should define the server-side template too, this template is used at your first and direct request:

.Template(@<text><input type='checkbox' name='checkedRecords' value='@Item.Id' /></text>)