PDA

View Full Version : Remember Selection for Paging Table



michik
25 Jun 2008, 4:12 AM
hi,

i have a paging table where i can select multiple lines for one page. if i page to another page (let's say from page 1 to page 2) to select another items and after page back to page 1, the items on page 1 are not selected anymore.

what can i do that the items, selected on other pages, stay selected?

greetings michi

darrellmeyer
25 Jun 2008, 8:15 AM
The table is only aware of the current data. If you wish to preserve selections, you will have to maintain the selection state yourself and apply the selections each time the data is changed.

michik
25 Jun 2008, 11:00 PM
thank you for your quick answere.

does this mean, that i have to implement my own SelectionModel for the Table
(e.g extend the TableSelectionModel)?

can you give me a hint.

i also thought about a checkbox for marking the item as selected, before each item. this would be a more elegant solution. what about that - is there a out-of-the-box solution?

gslender
26 Jun 2008, 12:28 AM
i think the easiest solution would be to build an array of the unique items selected as each item is selected - ie

ArrayList arrayOfSelectedItems = new ArrayList();

//somewhere else in selected item event

arrayOfSelectedItems.add(selecteditem);

neonzebra
27 Aug 2008, 11:42 AM
ok I've extended TableSelectionModel to intercept the selection changes via onSelectChange(). I use this to add/remove the selected items from the ArrayList.

Now the problem is when I change the page, onSelectChange() is triggered and the items are actually de-selected, removing them from my list. Is there a way to prevent onSelectChange() from being triggered when the page is changed?