是否可以将全局过滤器放在p:dataTable之外? [英] Is it possible to place the Global Filter outside the p:dataTable?

查看:69
本文介绍了是否可以将全局过滤器放在p:dataTable之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将p:dataTable的全局过滤器放置在表本身之外

I need to place the global filter of the p:dataTable outside of the table itself ,

我想将其放置在数据表所在的表格之外,但要开始将过滤器放置在数据表FORM内,但将其放置在数据表本身外就足够了

I would like to place it outside the form in which the datatable exists, but for start placing the filter inside the datatable FORM but outside the datatable itself will be enough

即使我将过滤器放在数据表FORM内但在数据表本身外,它也会停止工作(它在p:dataTable本身内工作100%)

Even when I place the filter inside the datatable FORM but outside the datatable itself , it stop working (it works 100% inside the p:dataTable itself)

这是过滤器本身的定义

<p:inputText id="globalFilter" onkeyup="myTableNameTable.filter()" style="width:150px;"/>  

推荐答案

我使用代理"按钮解决了该问题.

I solved the issue using a "proxy" button.

我用display:none样式设置包围<p:inputText id="globalFilter">h:panelGroup,如下所示:

I set the h:panelGroup that surrounded the <p:inputText id="globalFilter"> with display:none style, like this:

<h:panelGroup style="display:none">  

然后在完全不同的位置添加了输入文字

then added an input text in completely other place

<h:panelGroup id="myFilter" >
    <h:inputText id="myFilter_text" />
</h:panelGroup>

并绑定一个使用jQuery on()函数的JS函数(在较旧的jQuery版本中,您可以使用delegete()),如下所示:

And bound a JS function which uses the jQuery on() function (in older jQuery version you can use delegete()), like this:

    function searchKeyPressedHandler() {
        $(document).on("keyup", "#myFilter input", function (event) {
            var searchValue = document
                .getElementById('myFilter_text').value;

            $("#myTableId\\:globalFilter").val(searchValue);
            $("#myTableId\\:globalFilter").trigger('keyup')
        });
    }

使用了$()和on(),因为我正在使用其他jQuery 1.7.1库,否则我必须使用jQuery()而不是

Used the $() and on() because I'm using additional jQuery 1.7.1 library, otherwise I had to use the jQuery() and instead of

$(document).on("keyup", "#myFilter input",

我会用

jQuery(document).delegate("#myFilter input","keyup",... 

(只需切换第一个和第二个参数)

(just switched the first and the second arguments)

就是这样,我可以随意将过滤器输入放到我想放置的任何地方.

That's it, and I'm free to place the filter input where ever I want to.

这篇关于是否可以将全局过滤器放在p:dataTable之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆