This question is locked. New answers and comments are not allowed.
Hi,
I am trying to build a Grid which has a Template Column at the end. I also need to use the Custom Paging and Filtering using Ajax databinding. When the grid is initially loaded, every thing works fine and Template Column (containing a link) renders very well. But when I try to page to or apply Filter, the action completes successfully, but the Template Column no more holds any content (link). Its empty. Here are relevant parts of my code.
The extension methods ApplyPaging and ApplyFiltering have been used as per demo here
Any help please.
regard,
NIrvan.
I am trying to build a Grid which has a Template Column at the end. I also need to use the Custom Paging and Filtering using Ajax databinding. When the grid is initially loaded, every thing works fine and Template Column (containing a link) renders very well. But when I try to page to or apply Filter, the action completes successfully, but the Template Column no more holds any content (link). Its empty. Here are relevant parts of my code.
<!-- View -->
@{Html.Telerik().Grid(Model)
.Name("UserGrid")
.Columns(col => {
......
col.Bound(m => m.LastName).Title("Last Name");
col.Template(@<
text
>
@Ajax.ActionLink("Details", "UserDetails", new { Id = item.Id },
new AjaxOptions
{
OnBegin = "beginShowDetails",
OnSuccess = "showDetails",
UpdateTargetId = "_UserDetails"
})
</
text
>).Width(75);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_UserList","User"))
.Pageable(settings => {
settings.PageSize(15);
settings.Total((int)ViewData["count"]);})
.EnableCustomBinding(true)
.HtmlAttributes(new {@class="list-grid"})
.Filterable()
.Render();}
/* The Controller */
public
ActionResult UserList() {
List<User> users = GetListData(
new
GridCommand() { PageSize = 15 });
ViewData[
"count"
] = count;
return
View(users);
}
[GridAction(EnableCustomBinding=
true
)]
public
ActionResult _UserList(GridCommand command) {
List<User> users = GetListData(command);
return
View(
new
GridModel { Data = users, Total = count });
}
private
List<User> GetListData(GridCommand command) {
IQueryable<User> users = userManager.GetQueryableUsers();
users = users.ApplyFiltering(command.FilterDescriptors);
count = users.Count();
users = users.OrderBy(u => u.FirstName).ThenBy(u => u.LastName);
users = users.ApplyPaging(command.Page, command.PageSize);
return
users.ToList();
}
The extension methods ApplyPaging and ApplyFiltering have been used as per demo here
Any help please.
regard,
NIrvan.