-
1. Re: Get rich:column sortBy working
mcmurdosound Nov 21, 2011 9:57 AM (in response to jbossesblearner)since RF 4 you appearantly have to specify a sortOrder for each column in your bean.
Take a look into the example in the showcase:
<
rich:column
sortBy
=
"#{cap.name}"
id
=
"name"
sortOrder
=
"#{capitalsSortingBean.capitalsOrder}"
>
<
f:facet
name
=
"header"
>
<
a4j:commandLink
value
=
"Sort by Capital Name"
render
=
"table"
action
=
"#{capitalsSortingBean.sortByCapitals}"
/>
</
f:facet
>
<
h:outputText
value
=
"#{cap.name}"
/>
</
rich:column
>
and
private
SortOrder capitalsOrder = SortOrder.unsorted;
a more generic example can be found under:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
xmlns:h
=
"http://java.sun.com/jsf/html"
xmlns:f
=
"http://java.sun.com/jsf/core"
xmlns:ui
=
"http://java.sun.com/jsf/facelets"
xmlns:rich
=
"http://richfaces.org/rich"
xmlns:a4j
=
"http://richfaces.org/a4j"
xmlns:c
=
"http://java.sun.com/jsp/jstl/core"
>
<
ui:composition
>
<
rich:column
sortBy
=
"#{property}"
sortOrder
=
"#{bean.sortOrders[property]}"
filterValue
=
"#{bean.filterValues[property]}"
filterExpression
=
"#{property}"
>
<
f:facet
name
=
"header"
>
<
h:commandLink
action
=
"#{bean.toggleSort}"
>
#{bean.sortOrders[property]}
<
a4j:ajax
render
=
"richTable"
/>
<
f:setPropertyActionListener
target
=
"#{bean.sortProperty}"
value
=
"#{property}"
/>
</
h:commandLink
>
<
br
/>
<
h:inputText
value
=
"#{bean.filterValues[property]}"
>
<
a4j:ajax
render
=
"richTable@body scroller"
event
=
"keyup"
/>
</
h:inputText
>
</
f:facet
>
<
h:outputText
value
=
"#{record[property]}"
/>
</
rich:column
>
</
ui:composition
>
</
html
>
-
2. Re: Get rich:column sortBy working
jbossesblearner Nov 21, 2011 9:59 AM (in response to mcmurdosound)This was a really quick answer. Thanks a lot. I will try to use sortOrder.
-
3. Re: Get rich:column sortBy working
jbossesblearner Nov 21, 2011 11:36 AM (in response to mcmurdosound)Hello.
I tried it like in the more generic example. The column header is a link now. When the link is clicked, the new sortOrder is set, then the sortOrder property is requested
but somehow the table isn't rerendered. Any ideas?
-
4. Re: Get rich:column sortBy working
jbossesblearner Nov 22, 2011 4:28 AM (in response to mcmurdosound)Hello.
Now it works. First it didn' work, because I didn't define comparators.
I have another question. Aren't the sort icons available anymore in richfaces 4.0.0.Final? I think they are nice, because with them you can see after wich column the table is sorted.