MLS
MLS

Reputation: 196

FilterToolBar not returning all matches

I have a jqGrid with json data type and loadOnce: true. I am using the filterToolBar search. It does not return all matches. The grid contains a searchable column called Name and has values "Adkins, Joe" and "Adkinson, Jane". If I type in search string "Adk", the only match returned is "Adkins, Joe".

Here is the grid definition:

function loadmyGrid(dataUrl, selectUrl) {
$("#myGrid").jqGrid({
    url: dataUrl + "?r=" + rand(),
    datatype: "json",
    mtype: 'GET',
    rowNum: -1,
    loadonce: true,
    ignoreCase: true,
    scroll: true,
    scrollOffset: 0,
    gridview: true,
    colNames: ["Employee ID", "Name", "User Name", ""],
    colModel: [
              { name: "EmployeeID", width: "125", align: "center", sortable: false, resizable: false, title: false, search: false },
                    { name: "Name", width: "150", align: "center", sortable: false, resizable: false, title: false },
                    { name: "UserName", width: "125", align: "center", sortable: false, resizable: false, title: false, search: false },
                    { name: "UserKey", key: true, width: "135", align: "center", sortable: false, resizable: false, title: false, formatter: selectButtonFormatter, search: false},
            ],
    emptyrecords: "Nothing to display",     
    beforeSelectRow: function () { return false; },
    gridComplete: function () {
        $("#myGrid").setGridHeight("100%");
        $("#myGrid").filterToolbar({searchOnEnter: false, defaultSearch: "cn" })
    }
})

Upvotes: 4

Views: 124

Answers (1)

Oleg
Oleg

Reputation: 221997

Your main error is the usage of rowNum: -1 which is wrong. If you want to prevent local paging of data you should use some large enough value of rowNum. For example rowNum: 1000 or rowNum: 10000.

I recommend you additionally to replace $("#myGrid") inside of any callback (for example gridComplete) to $(this). The usage of "?r=" + rand() part of the url seems me unneeded. The call of $("#myGrid").filterToolbar you should move outside of gridComplete because it can be called only once.

I recommend you additionally to use column templates. It can reduce the code and could make it more manageable and better readable.

Upvotes: 2

Related Questions