Replies: 2 comments
-
As currently implemented, there's no explicit public API for "add a single item" or "refresh the item list". The current assumption is that the list of items is relatively static; you can re-assign the list of items on the widget, but manipulating the list of items won't be reflected. As a result, the apparently no-op statement: will actually fix the problem you're seeing, as you're explicitly using the A better construction would be to maintain the list of items you want as a separate list, and assign that list to the widget as Longer term, we intend to modify Selection to use a Source as the underlying list of items. This will provide the sort of APIs you're looking for where adding an item changes the list available for selection. As an aside: two small critiques of/suggestions for the sample code you've provided:
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the reply -- that was really helpful. I think I have re-factored the code per your suggestion (using a class attribute) and documented it in the following in case it helps others.
|
Beta Was this translation helpful? Give feedback.
-
The code below adds a button and a selection widget. Pressing the button appends additional Selection items into the internal list as shown in the image. However the additional items don't appear in the Selection widget. Why is this? Do I need to call the refresh in a different way, or am I appending items in the incorrect way?
Beta Was this translation helpful? Give feedback.
All reactions