3

This is a follow-up to my earlier question posted here. I have cases where we get large amount of data, around 200KB to be displayed on the jqgrid. In such case, the last sets of data are never displayed. Each record is split by a newline character. The data is in this format:

{"data":{"data":"\tat org.aaa.aaa.aaa.aaa.aaa.aaa(aaa.java:512)[147:org.aaa.aaa.aaa:9.1.1]\n\tat aaa.aaa.aaa.aaa.aaa.aaa(aaa.java:1789)[146:org.aaa:9.1.1]\n"}}

The code for grid is as follows:

$("#grid").jqGrid({
    type: "GET", 
    url: "/getdata",
    datatype: "json",
    colNames: [''],
    colModel: [
       {name: 'data', align: 'left', sortable: false}
    ],
    jsonReader: {
        root: "data",
        cell: "",
        id: function () {
            return function () {
                return $.jgrid.randId();
            }
        },
        page: function() { return 1; },
        total: function() { return 1; },
        records: function(obj) { return obj.data.length; }
    },
    loadonce: false,
    viewrecords: true,
    sortname:'',
    rowNum: '9999',
    autowidth: true,
    ignoreCase: true,
    height: "auto",
    multiselect: false,
    sortable: false,
    autoencode: true,
    loadComplete: function() {
         $("tr.jqgrow:even").css("background", "#DDDDDC");
    },
    // We will handle the errors with ajax error handlers for now
    loadError: function(error){
        displayError(error.responseText);
    },
    beforeProcessing: function (data) {
         var items = data.data.split("\n"), i, l, item;
         data.logs = [];
         for (i = 0, l = items.length; i < l; i++) {
            item = $.trim(items[i]);
            if (item.length > 0) {
                data.data.push([item]);
             }
         }
    }
});

I tried setting the rowNum to '', 99999, nothing worked. The total number of lines wwas The same lines seem to be getting chopped from display in jqgrid. Is there any limit to the amount of data that jqgrid can display? As of now, no pagination has been implemented on jqgrid.

Any pointers are greatly appreciated.

thanks,

Asha

Community
  • 1
  • 1
Alice
  • 390
  • 2
  • 5
  • 19

1 Answers1

3

First of all I recommend you to use correct type of all input parameters of jqGrid. In the documentation you will find the table which has "Type" column. The type of rowNum column is integer. So you should use rowNum: 9999 instead of rowNum: '9999'.

Additionally I strictly recommend you always use gridview: true option of jqGrid. In case of placing all data on one page such setting can improve the performance of filling of the grid in many times.

In the same way I don't recommend you to make any modification of the grid inside of loadComplete. It reduce the performance of jqGrid. You can define your custom CSS class for example

.myAltRows: { background: #DDDDDC }

and use the options altRows: true, altclass: "myAltRows". Alternatively you can use rowattr callback to set custom class or custom style on selected rows of the grid. See the answer for more details.

The last remark. I don't recommend you to include options which has default values (for example, type: "GET", loadonce: false, sortname:'', multiselect: false, sortable: false) or properties of colModel having default values (for example align: 'left'). You should examine default values column of the option and colModel options of the documentation.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks Oleg, you rock. It worked like a charm. Removing something as simple as default parameters speeds up the load and display. The data itself takes around 32ms to come from the back end, but after that the display on the jqgrid is fast. Thank you for pointing out my mistakes. – Alice Jan 30 '13 at 22:30
  • Also is there a way to specify to display all the rows. I can set rowNum to the max integer value, but want to know if there is a better way along the same lines as asked [here](http://stackoverflow.com/questions/1237096/how-to-show-all-rows-in-the-jqgrid) .I tried the approach of setting it to '' as mentioned, but it did not work. – Alice Jan 31 '13 at 01:03
  • @Asha: You are welcome! The usage of large enough value of `rowNum` is correct way to display grid without paging. The usage of max integer value I find not the best idea, because if one really would try to display 100000 rows if means some kind of error. The performance will be unexceptable for the user and no user will scroll examine *all* the rows. So I don't think that you should change `rowNum: 9999` which you currently use. – Oleg Jan 31 '13 at 06:02