简体   繁体   中英

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. The below javascript is being used to do the same :

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();' . 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().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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