-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi
As per the requirment, i need to sort by default based on column say lastname and i want to show the default icon given by zk.
Can someone help me on this.
Please note: List items are loaded from the DB when the page is loaded. After that user can click any header to sort. This part is working fine.
But i need to sort by default and i need to show that icon also.
<?page title="Listitem MVVM Demo with Hibernate" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Listitem MVVM Demo with Hibernate" border="normal"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('myvm') @init('domainVMS.PersonVM')">
<listbox id="test" model="@load(myvm.allPersons)"
selectedItem="@bind(myvm.curSelectedPerson)">
<listhead sizable="true">
<listheader label="First Name" width="400px" sort="auto(firstName)"/>
<listheader label="Last Name" width="285px" sort="auto(lastName)"/>
<listheader label="email" width="285px" sort="auto(email)"/>
</listhead>
<template name="model" var="p1">
<listitem onDoubleClick="@command('onDoubleClicked')">
<listcell label="@load(p1.firstName)" />
<listcell label="@load(p1.lastName)" />
<listcell label="@load(p1.email)" />
</listitem>
</template>
</listbox>
</window>
</zk>
Any help please................
Hi Senthil.
I believe that the easiest way to achieve this:
1st: On the first access to the page, fetch the data from the DB already sorted (say by lastname ascending)
2nd: On your zul: <listheader label="Last Name" width="285px" sort="auto(lastName)" sortDirection="ascending"/>
Another way would be using a Composer along side the ViewModel, and in the Composer you could trigger the onClick event on top of the listheader that should be sorted...
HTH,
Madruga
Perfect. Method 1 works fine. So let me follow that.
Thank you madruga. Your reply is very helpful.
Senthil M
Asked: 2012-06-16 08:38:04 +0800
Seen: 274 times
Last updated: Jun 18 '12