Catfish
Catfish

Reputation: 19284

Richfaces 3 datatable sorting not working

I've been googling this for 2 days now and trying various attempts that i've seen posted on the web, but nothing seems to be working for me.

I'm trying to get a richfaces 3 datatable to have sorted columns and when i click the column header, nothing actually gets sorted.

Anyone have any idea what i'm missing? Do i need to implement an attribute on my backing bean or something?

<rich:extendedDataTable id="resultsTable" value="#{tableBacking.results}" var="results" rowKeyVar="row">
        <rich:column>
            <f:facet name="header">
                <h:outputText value="Row Number" />
            </f:facet>                  
        </rich:column>

        <rich:columns value="#{tableBacking.columns == null ? '' : tableBacking.columns}" 
            var="columns" index="ind" id="column#{ind}" 
            sortBy="#{results[ind].data}" rendered="#{tableBacking.columns != null}">
            <f:facet name="header">
                <h:outputText value="#{columns.columnDescription}" />
            </f:facet>

            <h:outputText value="#{results[ind].data}" />

        </rich:columns>
    </rich:extendedDataTable>

TableLookupBacking bean

public class TableLookupBacking{
    private List<List<TableData>> results = null;
    private List<TableData> columns = new ArrayList<TableData>();

    public void search() {
        getData("");
    }

    private void getData(String whereClause) {

        try {
            DataDao dd = new DataDao();
            results = dd.getData(WebDataViewerConstants.SCHEMA_NAME, selectedTable, whereClause);
        } catch (Exception e) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Unable to retrieve data with selected search criteria in getData."));
        }
    }
// columns get set in another method that is triggered off something else the user does    

// Getters and Setters

}

Upvotes: 1

Views: 1599

Answers (1)

Catfish
Catfish

Reputation: 19284

I finally figured it out. All i needed to do was to add sortOrder="#{tableBacking.sortOrder[columns]}" to my rich:columns tag and then in my backer just add the following:

private Map<String, Object> sortOrder = new HashMap<String, Object>();

// setter and getter

Upvotes: 1

Related Questions