Binding richselect options to datatable

I’m new to webix and have a problem with binding a datatable and a richselect
component. I wrote this code:

http://webix.com/snippet/c0a338fc

Whenever the user selects an item in the datatable, the richselect options should adapt according to the ‘options’ attribute in ‘data’. However, all the options displayed are the same. What’s wrong with my code ?

At least I found out on my own: An ‘id’ has to be set explicitly for every element of the list. This was not obvious to me at first.

http://webix.com/snippet/0cde23ec

Its actually a bug, code must work with and without providing separate “id” for each item.

While component expects that data objects have “id” property, it can autogenerate IDs automatically. In case of the richselect it has sense to provide the “id” anyway, as richselect will return id of item when you will use getValue or similar API.

Thank you. But now another question evolved:
Unfortunately the option list does not update immediately when the selection is changed, but when the user opens the popup for the first time. What I’d like to achieve is the following:

  • richselect option list should update immediately on selection change in dataview, even if the popup is not opened
  • first item of option list should be selected
  • form should update according to selection
    I think I must emit an event which forces the richselect to update its option list and attach it to the dataview’s ‘onSelectionChanged’ event. Which is the best way to do this?

After a lot of testing and reading docs I found this:

http://webix.com/snippet/7ecac0a7

It doesn’t look very elegant and - to be honest - I don’t really know how it works.
Is there a better solution?