combo setValue by custom attribute value

I successfully adapt a previous snippet to fit my need. Just wondering if there is a better (normalized) way to do that ?

I mean something like : combo.setValueByAttribute(attributeName, value);

https://snippet.webix.com/fy92h71s

Hi @franck34

For a certain use-case, your solution is correct.
But as a side note, such references as

$$(this.config.suggest);
$$(this.config.suggest).getList();

Can be replaced correspondingly with methods available in suggest-based controls (combo, richselect, etc.):

this.getPopup();
this.getList();

where this is a control itself.
As for the common patterns of creating components, it will be better to keep $init free from massive functions added to $ready, so here’s an example of reworked structure: https://snippet.webix.com/44y14uwo


But if there is a possibility that combo has no displayField, it is better to use _setter for it in order to avoid errors. propertyName_setter executes some logic on component init if such property was specified in config, so you can do something like:

https://snippet.webix.com/64i8uifp

+1

I’ve already see _setter in the doc but i miss this useful aspect

Thank you listopad