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://www.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();
        }