简体   繁体   English

清除搜索过滤器后,重置pimefaces数据表

[英]Reset the pimefaces datatable when the search filters are cleared

I have a primefaces datatable where the search filter bar is shown and hidden on the click of a button. 我有一个primefaces数据表,单击按钮即可显示和隐藏搜索过滤器栏。 The below javascript is being used to do the same : 下面的javascript被用来做同样的事情:

function filters() {
var filterRow = $(".ui-filter-row");
if (filterRow.is(":visible")) {
$(".ui-column-external-filter").val('');
$(".ui-filter-row").hide();
} else {
$(".ui-filter-row").show();
}
}

When I am hiding the search filter bar, I am also clearing the text entered in the filter: 隐藏搜索过滤器栏时,还将清除在过滤器中输入的文本:

$(".ui-column-external-filter").val('');

But the datatable also should get reset or updated when the text in the filter is cleared. 但是,清除过滤器中的文本后,数据表也应重置或更新。 How do I achieve that? 我该如何实现?

How are filtering your data because in primefaces. 如何过滤数据,因为使用了素数。 If you refer showcase here . 如果您在这里参考展示柜。 It is way more easy to perform. 这是更容易执行的方法。

  1. oncomplete='datatablewidgetvar.filter();' . To perform filtering on the datatable. 对数据表执行过滤。

  2. To clear filtering you can use oncomplete='datatablewidgetvar.clearFilters();' 要清除过滤,您可以使用oncomplete='datatablewidgetvar.clearFilters();' . You have to write and ajax request or some sort of event which will catch that your filters are hidden and then call widgetvar.clearFilters(). 您必须编写并执行ajax请求或某种事件,以捕获过滤器已隐藏,然后调用widgetvar.clearFilters()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM