Clearing the filter text values in an iron-data-table programmatically

79 views Asked by At

I am using iron-data-table to display and select a user from a list of users. I have a need to clear all the filter values at once, and I don't know if there is a feature I may be missing in the API.

I have successfully changed the filter values in the object, then cleared the cache, resetting the list to a non-filtered list, like so:

this.$.list.filter[0].filter = "";
this.$.list.filter[1].filter = "";
this.$.list.clearCache();

However, even though the list is unfiltered, the text remains in the filter input fields.

Is there a built-in way to clear the text? If not, is there any simple way to reference the values of those generated filter input fields?

1

There are 1 answers

0
Joel H. On

One of the sub-elements of iron-data-table, data-table-column-filter, has a convenient value property. Basically, I did a query selector to get each data-table-column-filter element.

Once I had the list of elements, I iterated over them and set each value to "".

var elements = document.querySelectorAll('data-table-column-filter');
for (var i=0; i < elements.length; i++) {
    elements[i].value = "";
}