How to filter a list in combo

Hi Webix Team

Here our requirement is two fields(displayField & valueField) are displayed in combo list, if we filter the one field either displayField or valueField, the filter value is display in combo.

please follow the below snippet
https://webix.com/snippet/2c2f5f04

Thanks in advance
Deepak E

Hi,

Am I right that you intend to set dynamically

  • a value which will be displayed in input
  • a template which will be displayed in list
  • an attribute for inner interaction instead of default id

from the combo configuration?

While the 1st and 2nd are rather easy to implement with a simple templates ( https://webix.com/snippet/a5f3fef2 ), the 3rd option is not recommended for implementation, as all logic of Webix data components (including the list inside the combo) is based on the unique ID of an item.

Hi,

. If we search the df value means the df value will be displayed in input, otherwise if we search the vf value means the vf value will be displayed in input, is there any possibility??

find the below snippet
https://webix.com/snippet/d7f30739

Thank’s in advance
Deepak

There are different templates for list and input, both can be a function which can return any string/valid HTML depending on some condition.

https://webix.com/snippet/e20346bf

Hi Listopad

Thank’s for reply, why need to use button, is there any direct option once we search in input.

if we search df value means df value displayed in the input,
if we search vf value means vf value displayed in the input

Thank’s in advance
Deepak

why need to use button

Filtering function will be called for every item and in fact, without some strict condition for the value typed by user there’s no way to distinguish whether he/she searches for displayField or valueField.

If you have such condition, you can embed a custom flag into the combo view or add it to a combo-based component. Here’s an example of such logic:

https://webix.com/snippet/51a0872f

In the above snippet, there’s an assumption that searching for valueField is always contained pc.

thanks for your valuable reply

Hi Listopad thank’s for your reply

now we want to search via synonyms,
if we search df value means vf value should be hide,if we search vf value means df value should be hide,
plz follow the below snippet

https://webix.com/snippet/9a8b186c

Thank’s in advance
Deepak

The template in body can rely on the same type of logic except for one point: templates of data components (list, datatable, etc) have different scope and this here refers to the entire Window object, not to the component.

So in any case, you need to know the ID of the master combo or at least ID of a list on which you apply the template.

Hi Listopad

Really iam getting confusing in filter, plz help us, how to filter the name object(synonyms values in below snippet) in the combo

plz follow the below snippet
https://webix.com/snippet/bf6d650b

thanks in advance
deepak

Solution solved for above requirement, plz follow the below snippet
https://webix.com/snippet/5bcbdbc7