primeng icon indicating copy to clipboard operation
primeng copied to clipboard

DataTable reset() method doesn't clear all filter input fields

Open Svrkota-S opened this issue 9 years ago • 8 comments

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior DataTable's reset() method doesn't clear all filter input fields after it's called. If there's only one filter filled, it will clear it normally, but if there's more than one, data will still be displayed without any filters, but input fields will still have previously inputed values.

Expected behavior reset() method should clear all filter input fields.

  • Angular version: 2.4.5

  • PrimeNG version: 2.0.0-rc.2

  • Browser: All

  • Language: All

  • Node (for AoT issues): node --version = v6.3.0

Svrkota-S avatar Jan 30 '17 12:01 Svrkota-S

This can be replicated with custom filters only.If you use built-in filters then it won't cause this issue.The local component control values also need to be reset.

sudheerj avatar Jan 30 '17 14:01 sudheerj

That is not true, I'm simply using [filter]="true" filterMatchMode="contains" on all of my columns, there's no trace of anything custom.

Svrkota-S avatar Jan 30 '17 15:01 Svrkota-S

This is how I tried.

1.Filter on 3 columns without using custom filter feature

image

  1. After clicking on reset button all filter inputs got cleared and the table displayed with initial records

image

sudheerj avatar Jan 31 '17 12:01 sudheerj

+1. Can only be replicated with custom filters.

  1. Apply filters (normal and custom). Works as expected image

  2. Reset. Table reset with no filters. But the "selection" in the custom filter stays. In this example, I would have expected the Offset filter of 3 to be cleared too. It doesn't make sense for the filter text to not change when the filter was reset. Like it did for Well Name image

@Mrtcndkn - Could someone from your team please take a look at this?

bimalpaul avatar May 10 '17 13:05 bimalpaul

We can't know what are inside custom filters, so you need to clear them manually. Online example has a slider with manual clear.

cagataycivici avatar Jun 19 '17 12:06 cagataycivici

Could you please provide a link to said slider?

DraghiciR avatar Jun 21 '17 11:06 DraghiciR

@DraghiciR You can check it from over here: http://primefaces.org/primeng/#/datatable/filter

Mrtcndkn avatar Jun 21 '17 11:06 Mrtcndkn

I had similar issue with a custom filter with a primeng calendar, where it was only clearing it's filter after I forced called reset on the component using: @ViewChild(DataTable) dataTableComponent: DataTable; to access the datatable component methods, but the problem with this approach was that it resets all the filters. So I solved it by deleting the filter property manually on the onClearClick event of the calendar as follows:

onMyCalClearClick(){
    delete this.dataTableComponent.filters.myFilterProp; // work around to clear custom filter
    this.dataTableComponent.onLazyLoad.emit(); // here I force the datatable to refresh, bu maintaining the other filters if it has.
} 

viniciusalvess avatar Nov 20 '17 23:11 viniciusalvess