0

I am trying to load grid data virtually with jqGrid

My issue is, i have set the rowNum as 100. I am getting 100 unique records. Each unique record may have multiple sub records.

enter image description here

From the above image country and state make a uniques record and subrecords are city, attraction and zipcode.

I am using this example to group the row levels

Jqgrid - grouping row level data

my grid displays 100 unique records but with the above example i will be loading around 130 rows.

when i am trying to scroll and when i reach 70th row, second page of data is loading and overwriting the last few records of the first 100 unique records.

Please let me know what is best way to set the rowNum dynamically so that when i reach the last 100th unique record the it should load the second page of grid data.

Below is the code i am using.

$("#myTable").jqGrid({
    url: '../myUrl',
    mtype: "POST",
    shrinkToFit: false,
    width: null,
    height:505,
    datatype: "json",            
    page: 1,
    colModel: ospColModel,
    rowNum: 100,
    loadtext:"loading",
    onSelectRow: editRow,
    viewrecords: true,
    scroll: 1, 
    emptyrecords: 'Scroll to bottom to retrieve new page',
    jsonReader : {
        root:function(obj){
            return readRecords(obj);
        },
        page: function(obj){
            return obj.PageNum;
        },
        records: function(obj){
            return obj.TotalRecords;
        },
        total:function(obj){
            return Math.round(obj.TotalRecords/100);
        },
        repeatitems: false
     }
});
Community
  • 1
  • 1
Thanesh
  • 3
  • 4
  • I don't recommend you to use `scroll: 1`. If you need to load about 130 rows, then you should better use `loadonce: true` and to load all the data at once from the server. You can choose large enough value of `rowNum` (for example `rowNum: 1000`). It's important to write in every question, which version of jqGrid (can use) you use and from which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7). If you have to use an old jqGrid, then you should add `gridview: true` option. – Oleg Dec 03 '16 at 23:45
  • Thank you for the Information Oleg. Your inputs are helping lot of us. – Thanesh Dec 04 '16 at 21:45
  • Thank you for the Information Oleg. Your inputs are helping lot of us. I am using the old jqGrid version. I was able to solve this issue after 3 to 4 hours of research by changing the rowNum value Dynamically not sure if that is the correct way. As you told, Keeping rowNum to High value "1000" if i keep like this it is repeating the same records even though i kept repeatitems : false. I found this answer [link](http://stackoverflow.com/questions/30541610/jqgrid-dynamic-rownum-not-displaying-returned-rows) and i tried the way they told and it worked out. we are still testing – Thanesh Dec 04 '16 at 21:54
  • can you please share some code for how you are able to solve the repitionitems issue.Even we are facing the same issue, not able to resolve. – Vishnu Feb 21 '19 at 22:33

0 Answers0