Click here to Skip to main content
13,046,184 members (84,503 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Can someone help me with this issue?
I have a jqgrid(4.4.0) and I want to implement true scrolling. The problem is that it only loads datarows once, meaning the first page only. So when I scroll, it doesn't fetch the other pages. I have checked this link and still not working.

Here is the jqgrid:

            url: '@Url.Action("GetUserProjects", "TimesheetByWeek")',
            datatype: 'json',
            mtype: 'GET',
            colNames: ['Projekt', 'Oprettet af'],
            colModel: [
                        { name: 'project', index: 'project', sortable: true, align: 'left' },
                        { name: 'creator', index: 'creator', align: 'left' }
            height: 300,
            width: 250,
            altRows: true,
            pager: '#pager1',
            scroll: 1,
            rowNum: 15,
            rownumbers: true,
            viewrecords: true,
            sortname: 'project',
            sortorder: 'desc',
            gridview: true,
            caption: "Projekter",
            onSelectRow: function (ids) {
                if (ids == null) {
                    ids = 0;
                    if ($taskgrid.jqGrid('getGridParam', 'records') > 0) {
                        $taskgrid.jqGrid('setGridParam', { url: '@Url.Action("GetProjectTasks", "TimesheetByWeek")/' + ids });
                        $taskgrid.jqGrid('setCaption', "No Tasks " + ids).trigger('reloadGrid');
                } else {
                    var data = $("#deptProjectsGrid").getRowData(ids);
                    $taskgrid.jqGrid('setGridParam', { url: '@Url.Action("GetProjectTasks", "TimesheetByWeek")/' + ids });
                    $taskgrid.jqGrid('setCaption', "Tasks for " + data.project).trigger('reloadGrid');

The controller action looks like this:

public JsonResult GetUserProjects(int page, int rows, string search, string sidx, string sord)
                using (DanishEntities db = new DanishEntities()) 
                    int totalRecords = 0;
                    var allProjectEntities = _projectRepository.GetProjectsPaged(page, rows, out totalRecords, db);
                    var projects = Mapper.Map<List<Project>, List<ProjectModel>>(allProjectEntities);
                    var totalPages = (int)Math.Ceiling(totalRecords / (float)rows);
                    var jsonData = new
                        total = rows,
                        page = page++,
                        records = totalRecords,
                        rows = (
                                   from p in projects
                                   select new
                                       id = p.ID,
                                       cell = new object[] { p.Name, "john doe" }
                    return Json(jsonData, JsonRequestBehavior.AllowGet);
            catch (Exception)

and the query is:

public List<Project> GetProjectsPaged(int page, int rows, out int totalCount, DanishEntities dbContext)
            List<Project> pagedProjectEntities = new List<Project>();
                totalCount = dbContext.Projects.Count();
                pagedProjectEntities = dbContext.Projects
                        .OrderBy(p => p.ID)
                        .Skip((page-1) * rows)
            catch (Exception)
            return pagedProjectEntities;

I have wasted 4 hours of my life trying to figure this out and I just can't see the problem. I have even set "total = totalPages" in the controller action but nothing is working. Help please!!
Just another quick question on jqGrid: How do I disable "rowNum" in a jqGrid so that the grid shows all available rows returned by the query in the data set?
Posted 11-Sep-12 0:13am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100