0

Auto-sort is not working in Listbox in Zkoss 8.0.3

asked 2022-03-02 21:51:59 +0800

Omcsesz gravatar image Omcsesz
1

Hello, People!

I'm trying to use the auto-sort feature in a Listbox, as written in www.zkoss.org/wiki/ZKComponentReference/Data/Listbox#Auto-sortingonFields, by adding sort="auto" to the Listheader, but it does not work. What can cause this?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-03 15:39:40 +0800

MDuchemin gravatar image MDuchemin
2228 1 5
ZK Team

Hi there,

Autosorting requires a few things to work.

First, the row object must have an associated value. If you are using a template and model, there should be an implicit value assigned to the row. (the "each" object of the iteration).

Then, you need to declare which field you are filtering on, and that field has to be comparable to itself. (so a string, a number, etc) The auto sort will use a FieldComparator to compare the rows based on the field of the associated row value. Assuming that you have a pojo as value of the row, such as

class MyPojo {
  private String field1;
  private int field2;
  ... //getters setters
}

You would declare which of these fields you want to compare when sorting sort="auto(field1)" for example, will compare rows to each other based on the String field1

Hope that clarifies :)

If the sorting still doesn't work, I'd recommend trying to make a sample in zkfiddle

and posting it here for better answers ;)

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2022-03-02 21:51:59 +0800

Seen: 4 times

Last updated: Mar 03

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