This is a migrated thread and some comments may be shown as answers.

Server Custom Binding and Paging, GridCommand is not populated

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Amit
Top achievements
Rank 1
Amit asked on 27 Apr 2011, 12:13 AM
Model

public class ViewModel1
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}
 
public class ViewModel2
{
    public ViewModel2()
    {
        ViewModel1List  = new List<ViewModel1>();
    }
 
    public List<ViewModel1> ViewModel1List { get; set; }
 
    public int PageSize { get; set; }
    public int TotalCount { get; set; }
}

View

@model TelerikMvcApplication1.Models.ViewModel2
 
@{
    ViewBag.Title = "Queue";
}
 
<h2>Queue</h2>
 
@(Html.Telerik().Grid(Model.ViewModel1List)
    .Name("QueueGrid")
    .DataBinding(dataBinding => dataBinding.Server()
        .Select("QueueCustomBinding", "Home")
    )
    .EnableCustomBinding(true)
    .Columns(columns =>
    {
        columns.Bound(o => o.ID);
        columns.Bound(o => o.Name);
        columns.Bound(o => o.Description);
    })
    .Footer(true)
    .Pageable(paging => paging.PageSize(Model.PageSize).Total(Model.TotalCount))
    .Sortable()
)

Controller

public ActionResult Queue()
{
    var viewModel = this.BuildViewModel2();
 
    return View(viewModel);
}
 
[GridAction(EnableCustomBinding = true, GridName = "QueueGrid")]
public ActionResult QueueCustomBinding(GridCommand gridCommand)
{
    // gridCommand is NOT populated when the query string parameters are QueueGrid-size=2&QueueGrid-page=3
    // gridCommand is populated when the query string parameters are size=2&page=3
 
    // The paging links are rendered with query string parameters are QueueGrid-size and QueueGrid-page
 
    var viewModel = this.BuildViewModel2();
 
    return View("Queue", viewModel);
}
 
public ViewModel2 BuildViewModel2()
{
    var viewModel2 = new ViewModel2();
 
    viewModel2.ViewModel1List.Add(new ViewModel1 { ID = 1, Name = "Name1", Description = "Description1" });
    viewModel2.ViewModel1List.Add(new ViewModel1 { ID = 2, Name = "Name2", Description = "Description2" });
    viewModel2.ViewModel1List.Add(new ViewModel1 { ID = 3, Name = "Name3", Description = "Description3" });
    viewModel2.ViewModel1List.Add(new ViewModel1 { ID = 4, Name = "Name4", Description = "Description4" });
    viewModel2.ViewModel1List.Add(new ViewModel1 { ID = 5, Name = "Name5", Description = "Description5" });
 
    viewModel2.PageSize = 2;
    viewModel2.TotalCount = viewModel2.ViewModel1List.Count;
 
    return viewModel2;
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 27 Apr 2011, 09:22 AM
Hi Amit,

Could you please upgrade to the latest version and see if this makes any difference.

All the best,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Amit
Top achievements
Rank 1
answered on 03 May 2011, 10:50 PM
Updating to the latest version fixed it.

Thanks,
Amit
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Amit
Top achievements
Rank 1
Share this question
or