Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Remote Paging Help Needed!!
posted

HI,

 

I have tried to use the example provided in

https://ko.infragistics.com/community/forums/f/ignite-ui-for-javascript/77099/remote-paging/389378#389378

 

but it does not work. The grid shows 25 rows so I know that its hitting the customGridPaging element but it still only shows 1 page and a total of 25 records, when i set the customtotalrecordcount to 1000. And when i put a breakpoint in the

TransformDataSource method, it does not get hit 

 

Here is my front end grid:

@(Html.Infragistics().Grid<UsersViewModel>()
      .ID("grid1")
      .AutoGenerateColumns(false)
      .Columns(col =>
          {
              col.For(x => x.FullName).DataType("string").HeaderText("Name").Width("200");
              col.For(x => x.ManagerName).DataType("string").HeaderText("Manager").Width("150");
              col.For(x => x.ApprovingManagerName).DataType("string").HeaderText("Approving Manager").Width("150");
              col.For(x => x.Email).DataType("string").HeaderText("Email").Width("150");
              col.For(x => x.LastLoginDateString).DataType("string").HeaderText("Last Login").Width("150");
          })
      .Features(features =>
          {
              features.Selection().Mode(SelectionMode.Row);
              features.Filtering().Type(OpType.Local);
              features.Sorting().Type(OpType.Local);
              features.Features.Add(new CustomGridPaging()
              {
                  Type = OpType.Remote,
                  PageSize = 25,
                  CustomTotalRecordsCount =1000
              });
          })    
      .RowTemplate("<tr><td>${FullName}</td><td>${ManagerName}</td><td>${ApprovingManagerName}</td><td>${Email}</td><td>${LastLoginDateString}</td></tr>")    
      .DataSourceUrl(Url.Action("BindGrid"))
      .PrimaryKey("ID")
      .DataBind()
      .Render())

 Here is the customgridpaging file:

    public class CustomGridPaging : GridPaging
    {
        public int CustomTotalRecordsCount { getset; }
        public override void TransformDataSource(NameValueCollection queryString, IGridModel grid, out IQueryable queryable)
        {
            queryable = (IQueryable)grid.DataSource;
            this.TotalRecordsCount = this.CustomTotalRecordsCount;
        }
    }

Here is the controller action method:

        [GridDataSourceAction]
        public ActionResult BindGrid(int page, int pageSize) 
        {
           int startRow = (page - 1) * pageSize;
 
           PortalList<User> userData = SecurityService.GetUserList(startRow, pageSize);
            ViewBag.TotalRecords = userData.TotalRows;
            var userDataList = userData.List;
 
            Mapper.CreateMap<UserUsersViewModel>();
 
            var usersViewModel = Mapper.Map<List<User>, List<UsersViewModel>>(userDataList);
 
            return View("InfragTest", usersViewModel.AsQueryable());
        }
       public ActionResult InfragTest()
        {
            return View();
        }

 

Parents
  • 23953
    Suggested Answer
    Offline posted

    Hi Doug,

    The custom paging solution which I provided in the forum post you refer to (http://ko.infragistics.com/community/forums/p/77099/389378.aspx#389378) works only when you initialize the grid model in the controller using the GridModel class. The reason is that the chaining configuration is stateless i.e. it is executed only once when the View is created, thus the configuration cannot be recreated when an action method decorated with GridDataSourceAction attribute is executed.

    In fact GridDataSourceAction attribute creates a GridModel instance automatically behind the scenes. To do this it parses the query string and tries to guess which features are initialized by the grid, so it can include them in the GridModel instance. However it only initializes the feature classes provided in the Infragistics.Web.Mvc.dll, which means that it cannot initialize your custom class. That's why your breakpoint is not hit.

    Please, use the sample I provided in order to see how to configure the custom grid paging in controller.

     

    Hope this helps,
    Martin Pavlov
    Infragistics, Inc.

Reply Children
No Data