Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Re-sort listview after some change #1016

Open
sith opened this issue Jun 18, 2019 · 17 comments
Open

Re-sort listview after some change #1016

sith opened this issue Jun 18, 2019 · 17 comments

Comments

@sith
Copy link

sith commented Jun 18, 2019

How can I re-sort elements of ListView after some event occurred( e.g. checkbox is selected)?

Is there a manual that describes how to apply filtering and sorting?

@edvin
Copy link
Owner

edvin commented Jun 18, 2019

TornadoFX has a SortedFilteredList which should help you out :) Check the guide for usage examples.

@sith
Copy link
Author

sith commented Jun 18, 2019

I figured it out but this gives no results https://edvin.gitbooks.io/tornadofx-guide/?q=SortedFilteredList.

Which guide are you referring too?

@sith
Copy link
Author

sith commented Jun 20, 2019

sos!?

@edvin
Copy link
Owner

edvin commented Jun 20, 2019

Looks like that info hasn't been moved to the guide yet, so it's in the Wiki still:

https://github.com/edvin/tornadofx/wiki/Utilities

@sith
Copy link
Author

sith commented Jun 24, 2019

It is still not clear how to trigger re-sorting when some event happened

@edvin
Copy link
Owner

edvin commented Jun 25, 2019

Not sure what you mean. The page I linked to states "You can force a refilter by calling the refilter() function.". Is that not what you're after?

@sith
Copy link
Author

sith commented Jun 25, 2019

My listview has list of items which checkboxes. I want to show un-checked items on the top of the view and checked at the bottom. When use selects-unselects checkbox I want list to be re-sorted so item moves to a proper area. I am not sure refilter() will do it.

@sith
Copy link
Author

sith commented Jun 29, 2019

sos

@edvin
Copy link
Owner

edvin commented Jun 29, 2019

Seems like you just want to sort the table based on the boolean field the checkbox is bound to, is that it?

@sith
Copy link
Author

sith commented Jun 29, 2019

Yes exactly. It is a simple task list where I want to sort items based on it's status(open/done). So every time the task is mark as done I want to re-sort list so it goes down

@sith
Copy link
Author

sith commented Jul 4, 2019

bump

edvin pushed a commit that referenced this issue Jul 4, 2019
@edvin
Copy link
Owner

edvin commented Jul 4, 2019

I've updated the TodoList demo app with a solution to this :)

@sith
Copy link
Author

sith commented Jul 4, 2019

This example works with tableview, is there way to make it work with listview?

@sith
Copy link
Author

sith commented Jul 4, 2019

Looking at the code I see that comparator in SortedFilteredList is not set:
I created pull request - #1024

@sith
Copy link
Author

sith commented Jul 5, 2019

I think the pull request is not necessary. When I create SortedFilteredList I can add my comparator like this
SortedFilteredList<MyItem>().apply { sortedItems.comparatorProperty().bind(itemComparatorProperty) }
after this I can call refilter() function when checkbox is selected/unselected.

@sith
Copy link
Author

sith commented Jul 5, 2019

The follow up question is if there is a way to animate addition/deletion/resorting/refiltering items. As of now UI changes too quickly. It would be better if modifications to listview were more visible so user can see what is going on

@edvin
Copy link
Owner

edvin commented Jul 5, 2019

No, I don't think ListView has any built in animation capabilities. It's pretty easy to set the comparator, but we could sure make it more convenient. I'll look at your PR and see if that's the way to go or not :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants