How to clear filter text in select control?


#1

Hi,
I am using onItemTap event to refresh select control data and also want to clear/set filter input value.
Is there any built-in possibility to access filter of the select control in Angular?

Thanks!


#2

Hi @Fredrik_Landh,

You can reach the filter input by querying the DOM in the onItemTap event like this:

import { mobiscroll, MbscSelectOptions } from '@mobiscroll/angular';
...

settings: MbscSelectOptions = {
  filter: true,
  onItemTap: function(event: any, inst: any) {
    mobiscroll.$(event.target)
      .closest('.mbsc-fr')
      .find('.mbsc-sel-filter-input')
      .val('');
  }
}

And the markup:

<mbsc-select [options]="settings" [data]="myData"></mbsc-select>

Let me know if that works!
Best,
Zoli


#3

Hi Zoli!

Seems that’s the only possible workaround at the moment. Using same fix but with plain js.
Do you think that we can expect filterText property or method on the select component in the near future?

Thank you!


#4

You’re right, currently this is the only workaround. I created a feature request to solve this in the future. Thanks for the interest.

Zoli