Dynamically Add listbox Item to an ObservableCollection - listbox

I have a listbox that I have bound to an Observable collection. At runtime I would like the user to click a button and add thier own custom ID and Name to the listbox.
How do I do that when the listbox is already bound to an Observable collection?
THank you

When the user clicks the button add the item to the observable collection and the listbox should automatically update. If not, call databind on the listbox after it's been added to the collection and this will rebind the data to the listbox updating it

Related

What event to call when ListView selected item changed?

I'd like to run a procedure--once--whenever the selected item in a ListView changes. The obvious choice would be OnSelectItem, but it's called twice when the user moves from one selected item to another (using mouse or arrow keys). Similarly, OnChange is called three times when moving between items.
Is there an event generated only once under these conditions? OnClick is generated once, but doesn't cover moving between items using arrow keys, etc.
You can do it like this using OnSelectItem.
Remember the last selected item.
When the OnSelectItem fires, check if the current selected item differs from the one you remembered.
If so, perform your task, and make a note of the new selected item.

How to get the selected item ids from multi selectable combo box in Vaadin?

I want to get the selected item ids in a String array (preferably). How to get the selected item ids when multiple items are selected?
The documentation is often helpful :-)
You can select an item with the corresponding setValue() method. In multiselect mode, the property will be an unmodifiable set of item identifiers. If no item is selected, the property will be null in single selection mode or an empty collection in multiselect mode.
So after casting comboBox.getValue() to Set<?> you can call toArray(new String[0]) to get the desired array.

TListbox - OnChangeEvent does not fire reliable on multiselect

I'm using XE7 and FMX.
My problem is that the OnChange-Event for TListbox works not correctly with multiselect (it does not fire everytime when a change occured).
Steps to reproduce:
Create a FMX-application and add a TListbox to his form.
Add items to this listbox.
Set 'MultiSelectStyle' of Listbox to 'default'.
Handle the OnChangeEvent (set a breakpoint or do something ...).
Now run the project and click on the first Item -> OnChange is executed.
But if first item is clicked again the OnChange will not be executed.
Can tell me somebody how I can fix this, so that everytime when a the selection changes I get a event.
From documentation FMX.ListBox.TCustomListBox.OnChange:
Occurs when the selection in the list box changes.
Write an OnChange event handler to take specific action immediately after a new item or items are selected in the list box.
Use the OnClick or OnItemClick event instead to monitor when the user reselects the same selection. And keep the OnChange handler for all new selections.

jquerymobile - selectable list item

I want to be able to select a listview item. On select/click I can use onclick event and add class to that li. But, is there any default way in which I can select an item in the listview. I mean, when I select, it should be highlighted and I should be able to get the selected value.
The jQM listview widget does not include any default functionality for a highlighted/selected item. Your approach of
handling the click,
adding a class, and
storing the currently
selected item in a global or data-attribute
is a good way to go.

jquery sortable - how to prevent item from dragging from one list to another

There are two sortable UL elements which are linked to each other via 'connectWith' options so that items from one list can be moved to another list and vice versa. I'm in need to prohibit from moving/dragging some items to another list while still letting them to be draggable within their own list. Is there any way to implement such behavior?
For now I can only restrict items from dragging using 'items' option of those sortable lists but while this prevents the desired items from dragging to another list this also prevents those items from dragging within their own lists (which is bad).
The way I was able to get around this is by using the li elements onMouseDown and onMouseUp events. When the mouse is clicked, I changed my CSS class (or whatever else) so that it falls out of the items list.

Resources