-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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?
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 ;)
Asked: 2022-03-02 21:51:59 +0800
Seen: 4 times
Last updated: Mar 03 '22
ZK Listbox Selectitems issue with Set
How to stop a bug from a listbox?
Cannot Change Listbox Header color & Background
Keyboard navigation in listbox
Can not display data in listbox
listbox with nonSelectabletags inplace new listitem
Input invoice using inline listbox
Change color to hover listitem listbox zk7 + Atlantic Theme
Listbox with autopaging causes constant row flickering
zk listbox getItems() returns null for item.getValue() if not scrolled fully