-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I'm implementing a feature to delete all the selected elements of a listbox, the listbox's model is binded to a composer List:
<listbox id="listBoxBooks" model="@{wnd$composer.booksModel}" checkmark="true" multiple="true" fixedLayout="true" width="500px"> <listhead> <listheader label="ID" sort="auto(id)" width="50px"/> </listhead> <listitem self="@{each=book}" value="@{book}"> <listcell label="@{book.id}"/> </listitem> </listbox> <button id="btnDelete" label="Delete Selected"/>
Now on my composer I've the code to delete the selected books from the database:
ListModel booksModel public void onClick$btnDelete() { if (listBoxBooks.selectedCount > 0) { // delete the books from the database // get the new list of books booksModel = new BindingListModelList(books, false) binder.loadAll() } }
After I delete some books the listbox isn't automatically updated I have to refresh the hole page to get the updated list of books. I've already tried to invalidate the listbox component with no luck.
How could I update the listbox after I delete some elements?
Regards
Felipe, I'm not sure, but I think it could be from the fact that you're creating a new BindingListModelList. See what happens if you try this:
ListModel booksModel public void onClick$btnDelete() { if (listBoxBooks.selectedCount > 0) { // delete the books from the database // get the new list of books booksModel.clear(). booksModel.addAll(books) ; binder.loadAll() ; } }
and set a breakpoint in your getBooksModel() so you can examine what books are being returned to the data binder.
HTH,
Thank you cary. It solved the problem and a flush after the delete :)
Asked: 2009-12-10 07:19:14 +0800
Seen: 1,105 times
Last updated: Dec 10 '09