Telerik grid with checkbox - Checkbox not showing up when the grid initially paints

喜夏-厌秋 提交于 2019-12-24 07:07:58

问题


I have a telerik grid with a checkbox. I am using a client template. There is a .DataBinding Ajax call attached.

When the grid initially comes up, instead of a checkbox, it has the id value as text. If I hit refresh, the ajax call gets executed and when it comes back the checkbox appears. Is there any way to force the ajax call to happen when the grid initially paints so that I have a checkbox and not text ...

Code sample:

<% Html.Telerik().Grid(Model.AdminSongQueue)
    .Name("Grid")
    .Columns(columns =>
        {
            columns.Bound(o => o.UserTrackAssignmentID)
               .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= UserTrackAssignmentID #>' />")
               .Title("Check")
               .Width(50)
               .HtmlAttributes(new {style="text-align:center"});           
        })
    .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("_CheckBoxesSongGrid", "RightsToolSvc"))
    .Scrollable()
    .Pageable()
    .Render();
%>

回答1:


Yes, this is possible: You just have to call the empty constructor of the Grid class like this and the grid binds by calling the ajax select method for the initial data load, too:

Html.Telerik().Grid<YourModelDataType>().Name("Grid")...



回答2:


In my View (viewname.cshtml, MVC) I added the following before my .ClientTemplate:

     .Template(
 @<text> <input type='checkbox' id='chkMessage' name='checkedMovies' value='<#= ID #>' /> </text>)

...

This post is related, I found my answer here



来源:https://stackoverflow.com/questions/4249736/telerik-grid-with-checkbox-checkbox-not-showing-up-when-the-grid-initially-pai

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!