开发者

jqgrid filter removes one row on load once

I constructed one grid using jqgrid and I have enabled filtering. The datatype retrieved is json and i'm using the loadonce feature. When I apply some filters it appears that it always hides on record. I'm using a grid pager just to have the extra buttons that i want to add on the grid and i'm removing the gridpager buttons (next, last, etc..). I removed the pager to see if there was any conflict but still i get the same error. When the grid loads i'm getting 'View 1 - 7 of 7' and i can see 7 records, when I'm applying a filter the output is 'View 1 - 3 of 4'. Which means that 4 records match the filter but it keeps displaying only 3. Now if i clear the filters i get 'View 1 - 6 of 7', again one record is missing. I checked the table with firebug to see if the record is hidden but still nothing. I tried firefox, chrome, IE and in all browsers i get the same error. The jqgrid version is 4.1.1. Any clues why this is happening?

Below you can see the code:

jq($grid).jqGrid({
    url: $url,
    datatype: 'json',
    mtype: 'Get',
    colNames: colNamesList,
    colModel: $colModel,
    jsonReader : {
        repeatitems:false,
        id: "id",
    },
    rowNum: -1, 
    width: jq(document).width()-20,
    height: 200,
    pager: $pagerId,
    viewrecords: true,
    fixed: true,
    shrinkToFit: false,
    loadonce: true, 
    caption: $caption,
    beforeRequest: function(){
        if (!initialized) {
            jq(blockElement).block({ message: '<h1 class="loadingMsg">Grid is loading, please wait...</h1>' });
     开发者_JAVA百科   }
    },
    loadComplete: function(data){
        if (loadCompleteCallback != null){
            loadCompleteCallback(data);
        }

        if (!initialized) {
            jq.jGrowl('"' + $caption + '" Grid loaded.', {header:'Load Notification'});
            jq(blockElement).unblock();
            initialized = true;
        }
    }
});

        if (!initialized) {
            jq.jGrowl('"' + $caption + '" Grid loaded.', {header:'Load Notification'});
            jq(blockElement).unblock();
            initialized = true;
        }
    }
});

jq($grid).jqGrid('filterToolbar',{
    stringResult: true,
    searchOnEnter : false
});

Thanks in advance!


I don't understand the following: why you return from the server one row which you never want to show? Is it not easier to remove the data already on the server side? If it is not possible you can remove the row inside of loadComplete. By the way in the current code I can't see where you set custom filter which makes one row of the grid invisible.

One more remark: You should never use rowNum: -1. Only positive values (like rowNum: 10000) are permitted. It's especially important if you use loadonce: true which chynges the datatype to 'local' after the first filling of the grid. The usage of negative rowNum are not permitted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜