javascript 没有列过滤器的primefaces全局过滤器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10701841/
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-26 10:45:22  来源:igfitidea点击:

primefaces global filter without the column filters

javascriptfilterdatatableprimefaces

提问by neeraj narang

I'm working on the example mentioned in primefaces showcase. I am trying to create a global filter for the datatable.
Currently the table looks like this: enter image description here

我正在处理 primefaces展示中提到的示例。我正在尝试为数据表创建一个全局过滤器。
目前该表如下所示: 在此处输入图片说明

What I want to do is remove the individual column filters and have only the global filter. Like this: enter image description here
To do that I remove the filterByattribute on the column definitions. But on doing that, I get a javascript warning - Error in parsing value forfilter, declaration droppedand the global filter doesn't work.
Could someone please tell me how to achieve this?

我想要做的是删除单个列过滤器并只有全局过滤器。像这样: 在此处输入图片说明
为此,我删除filterBy了列定义上的属性。但是这样做时,我收到了 javascript 警告 -Error in parsing value for过滤器, declaration dropped和全局过滤器不起作用。
有人可以告诉我如何实现这一目标吗?

回答by Daniel

Make sure you have the filterBy="#{myRowVar.sonmeField}"in every p:column(because the global filter needs it)

确保你有filterBy="#{myRowVar.sonmeField}"in every p:column(因为全局过滤器需要它)

And also add the filterStyle="display:none"in every p:column(adding of filterStyle="display:none"will make it not visible...)

filterStyle="display:none"在每个中p:column添加(添加filterStyle="display:none"将使其不可见......)

回答by asdrubal

or you can just put:

或者你可以只放:

.ui-column-filter{
     display: none !important;
}

in your .css to hide all column filters

在您的 .css 中隐藏所有列过滤器