0

ListModelList and filter

asked 2023-07-10 21:55:02 +0800

holos gravatar image holos
27 5

For my MVVM "listbox binding" I switched from java.util.List to ListModelList and I gained a lot of benefits like keeping selection, scroll into view, performance, ...).

There is only one downside: filtering.

Whenever I need to display just a subset of the ListModelList I always have to create a new instance of ListModelList.

Originally I had the idea to have a stable java.util.List embedded into a ListModelList being manipulated using the features like "model.add, model.remove, model.set, model.notifyChange".
But this idea does not work with filtering.

My hope was to just embed a filter into the ListModelList that will control the getter (getAt()) and the size (getSize())- as:
"do not get an item if it does not match the filter and calculate the size accordingly".

I now use a workaround which makes the non-matching listitems "invisible".

<listitem visible="@load(vm.isVisible(org))">

But this needs a NotifyChange of the entire model. Funfact: If I apply the paging mold to the listbox it still reports many pages even if the filter matches just 1 item!

I also did some experiments with

public class SearchListModel<E> extends AbstractListModel<E> implements ListSubModel<E> {}

but the method ListModel<e> getSubModel() should return an instance of "ListModel" - and here comes the problem mentioned before.

Any ideas - or at least a hint how I can achieve the "do not get the item if it does not match the filter and calculate the size accordingly" thingy?

delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2023-07-10 21:55:02 +0800

Seen: 3 times

Last updated: Jul 10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More