-
1. Re: rich:datatable and sorting (data table)
kragoth Aug 25, 2009 1:58 AM (in response to jonhsmith)Take a look at the doco for a rich:dataTable
rich:dataTable DocoAs a standalone component the rich:dataTable does not offer sorting. There are two ways you could add sorting.
Change your headers to be links then make the click on the link do the sorting for you in an action method in your SEAM bean. Alternativly have a look at the rich:extendedDataTable component. This component offers sorting out of the box. You will need to read the rich:extendedDataTable Doco though to get it working. It can be a litte tricky at first. -
2. Re: rich:datatable and sorting (data table)
jonhsmith Aug 25, 2009 3:47 AM (in response to jonhsmith)The dafaul component rich:dataTable does offer sorting. I did that with this code:
<rich:dataTable id="table" var="record"
value="#{tableBean.values}" rows="10" width="100%">
<rich:columnGroup>
<rich:column sortBy="record.value1">
<f:facet name="header">
<h:outputText value="Column1" />
</f:facet>
<h:outputText value="record.value1"/>
</rich:column>
<rich:column sortBy="record.value2">
<f:facet name="header">
<h:outputText value="Column2" />
<h:outputText value="record.value2"
</f:facet>
</rich:dataTable>
Whith that code I got: (with ascendent/descendent sorting from richfaces to column1 and column2)
column1 | column2 |
value1 | value2 |
value1 | value2 |
value1 | value2 |
value1 | value2 |
value1 | value2 |
value1 | value2 |
BUT I DON'T KNOW HOW ADD TO THIS TABLE THE THIRD COLUMN WICH iS DIVIDED INTO THREE SUBCOLUMNS
column1 | column2 | column3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 | -
3. Re: rich:datatable and sorting (data table)
kragoth Aug 25, 2009 4:17 AM (in response to jonhsmith)Hmm, sorry about that... I better go back and read that doco again :S
Anyways, why can't you just move your column headers out into the facet section on their own and then use colspan=3 your third column header?
Like this:
<rich:dataTable> <f:facet name="header"> <rich:column sortBy="#{record.value1}"> <h:outputText value="column1"/> </rich:column> <rich:column sortBy="#{record.value2}"> <h:outputText value="column2"/> </rich:column> <rich:column colspan="3" sortBy="#{record.s1}"> <h:outputText value="column3"/> </rich:column> </f:facet> <rich:column> <h:outputText value="#{record.value1}"/> </rich:column> <rich:column> <h:outputText value="#{record.value2}"/> </rich:column> <rich:column> <h:outputText value="#{record.s1}"/> </rich:column> <rich:column> <h:outputText value="#{record.s2}"/> </rich:column> <rich:column> <h:outputText value="#{record.s3}"/> </rich:column> </rich:dataTable>
-
4. Re: rich:datatable and sorting (data table)
kragoth Aug 25, 2009 4:19 AM (in response to jonhsmith)hmm, I think I missed you doing some of what I said cause your code is all out of format. Can you surround your code with ` so that it gets formatted better and is easier to read.
-
5. Re: rich:datatable and sorting (data table)
jonhsmith Aug 25, 2009 5:13 AM (in response to jonhsmith)the problem is move the column headers out into the facet section on their own and then use colspan=3 your third column header. When i do that i lost the sorting functions. the sorting icons does not appear.
I don't know how to generate the table with this format yet. Where column1 and column2 are ascendet/descendent sorted by richfaces
column1 | column2 | column3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |
value1 | value2 | s1 | s2 | s3 |