jQgrid toolbar searching - dynamically remove sear

2019-06-25 19:39发布

问题:

I am using jqgrid version 4.4.4 and right now I am facing one problem related to toolbar searching. As I mention in heading, I want remove search box of toolbar search from any column "dynamically" during or after rendering a grid. I google it but I didn't found any relevant solution on my this problem. I used selColProp property like this

$('#<gridId>').jqGrid('setColProp', 'LotNo', {
    search: false
});

and mentioned in loadcomplete function due to some logical reason. If anyone knows how to do this, kindly share your valuable ideas.

UPDATED: Now I am using free jqgrid version 4.9.2 and this functionality also not happening on it.

回答1:

Searching toolbar will be created once. It includes all searchable columns in the searching toolbar. If you need to change the search property dynamically then you have to recreate the searching toolbar after changing the value of search property. You need just call destroyFilterToolbar to remove the searching toolbar and then call filterToolbar once more time.

Alternatively you can consider just to hide the searching field after setting the search property to false. The corresponding code could be something like

$("#gs_LotNo").closest(".ui-search-table").hide();

The string gs_LotNo is the id of the input field of the LotNo column. and using $("#gs_LotNo").closest(".ui-search-table") you get the outer table which contains optional searching menu and x button. You can consider to make the content of the field empty ($("#gs_LotNo").val("")) before hiding to be sure that the current value in the input field will not be used in filters.