datatable sorting by rich:columns and subTables
alibsd Jun 9, 2009 1:34 PMHi,
I'm working on creating a master/detail table with subTables (details) and a column
with colspan equals to number of columns (master).
The problem I have is that I can't figure out how to do that with richfaces components.
Since I want to use rich:column's sorting feature, I this I have to use rich:column and its
corresponding attributes such as sortOrder and sortBy, but all examples I've seen
which have used subTables, draw table's header with header facet of rich:dataTable.
The closest solution which I've found until now is:
<!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:c="http://java.sun.com/jsp/jstl/core"
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">
<body>
<h:form>
<rich:dataTable id="grid" rows="#{gridBean.pageSize}"
value="#{gridBean.rows}" var="row">
<rich:column id="top" rendered="#{gridBean.inGroupingState}"
colspan="#{gridBean.numCols}">
<h:outputText rendered="#{not row.collapsed}"
value="#{row.title} (#{row.totalCount})" />
<a4j:commandLink id="openGrp" actionListener="#{row.openGroup}"
rendered="#{row.collapsed}" reRender="grid"
value="#{row.title} (#{row.totalCount})" />
<rich:spacer width="20px;" />
<a4j:commandLink actionListener="#{row.expand}"
disabled="#{not (row.toIndex lt row.totalCount)}" reRender="grid"
value="MORE" />
</rich:column>
<rich:subTable id="sub" rendered="#{gridBean.inGroupingState}"
value="#{row.members}" var="member">
<rich:columns index="index" id="column#{index}" sortBy="#{col}"
sortOrder="#{gridBean.sortOrders[col]}" value="#{gridBean.columns}"
var="col">
<f:facet name="header">
<h:outputText value="#{col}" />
</f:facet>
<h:outputText value="#{member[col]}" />
</rich:columns>
</rich:subTable>
<f:facet name="footer">
<rich:datascroller id="scr" for="grid" />
</f:facet>
</rich:dataTable>
</h:form>
</body>
</html>
As you can guess, by this code, each subTable has its own header for sorting,
but I want to have SINGLE header for the hole table.
Sorry if my question is simple, but I would be so grateful if someone help me, and
tell me how can I do this.