javascript jqGrid:如何隐藏搜索工具栏中的特定搜索字段

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4602505/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 14:16:33  来源:igfitidea点击:

jqGrid: how to hide a specific search field in the search toolbar

javascriptcssjqgrid

提问by Atticus

I am using jqGrid with a search toolbar. Now for several columns I do not need the search field, because I do not want to make them searchable (i.e. a column of checkboxes). For these columns I want to hide the search field in the search toolbar. I have read in the jqGrid documentationthat the viewableoption can be set to false. Here is the part where I set the viewableoption:

我正在使用带有搜索工具栏的 jqGrid。现在对于几列我不需要搜索字段,因为我不想让它们可搜索(即一列复选框)。对于这些列,我想隐藏搜索工具栏中的搜索字段。我在 jqGrid文档中读到该viewable选项可以设置为false. 这是我设置viewable选项的部分:

colModel :[ 
          {name:'checkbox', index:'checkbox', width:'3%', viewable:false},

Here is how I create the search toolbar:

这是我创建搜索工具栏的方法:

jQuery(function(){
    jQuery("#listTable").jqGrid('filterToolbar',{stringResult: true, searchOnEnter: false});
});

According to the documentation, the viewableoption is valid only if the viewGridRowmethod is activated.

根据文档,该viewable选项仅在viewGridRow激活该方法时才有效。

But when I use (activate) the viewGridRowmethod, that creates another dialog. In that dialog the column whose viewableis set to false does not appear. But I want to hide the search field in the search toolbar not in a new dialog. How can I do that?

但是当我使用(激活)该viewGridRow方法时,会创建另一个对话框。在该对话框中,viewable设置为 false的列不会出现。但我想隐藏搜索工具栏中的搜索字段,而不是在新对话框中。我怎样才能做到这一点?

I have also tried to get the corresponding div(the one that surrounds my search field) and set its style.displayto none. But that does not help.

我还尝试获取相应的div(围绕我的搜索字段的那个)并将其设置style.displaynone. 但这无济于事。

Is there a way I could hide this search field in the search toolbar?

有没有办法在搜索工具栏中隐藏这个搜索字段?

回答by Arun P Johny

In your column model add the option search:falsefor the column where you do not want the search filter. Ex:

在您的列模型中,search:false为您不需要搜索过滤器的列添加选项。前任:

{
    label : 'User',
    name : 'name',
    width : 500,
    sortable : false,
    search : false
}

You can find the documentation here.

您可以在此处找到文档。