How to set the default column for the search box in jqGrid?

前端 未结 1 1756
星月不相逢
星月不相逢 2021-01-22 19:56

I have specified which columns are searchable through the colModel, but I can\'t find a way to specify the default column when the search box is opened.

Any

1条回答
  •  一生所求
    2021-01-22 20:37

    There are option columns which is not documented in the list of searching options. I wrote recently the answer and the demo which demonstrate how you can implement your requirement.

    UPDATED: If you use multipleSearch: true option then you can just follow the referenced answer and specify columns option like I described. The corresponding demo you find here. If you don't like that multipleSearch: true option don't display any searching rule per default you can just add default rule in filters property of postData. For example the next demo is identical to the previous one but it uses additionally

    postData: {
        filters: {groupOp: "AND", rules: [{field: "amount", op: "eq", data: ""}]}
    }
    

    option.

    If you don't want to use multipleSearch: true option then one have to fix small bug in jqGrid to be able to use columns option. One have to modify the lines (see the line 7009 in jquery.jqGrid.src.js) from

    } else {
        columns = p.columns;
    }
    

    to

    } else {
        columns = p.columns;
        cmi = 0;
        colnm = columns[0].index || columns[0].name;
    }
    

    I will post the bug report later to trirand and I hope that the bug will be fixed in the next version of jqGrid.

    The demo demonstrate working of the suggested fix.

    0 讨论(0)
提交回复
热议问题