问题
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