<p>I have a data table with a variable number of columns and a data scroller. How can I enable server side sorting? I prefer that it be fired by the user clicking the column header.</p>

<pre><code>&lt;rich:datascroller for="instanceList" actionListener="#{pageDataModel.pageChange}"/&gt;
&lt;rich:dataTable id="instanceList" rows="10" value="#{pageDataModel}"
                var="fieldValues" rowKeyVar="rowKey"&gt;
  &lt;rich:columns value="#{pageDataModel.columnNames}" var="column" index="idx"&gt;
    &lt;f:facet name="header"&gt;
      &lt;h:outputText value="#{column}"/&gt;
    &lt;/f:facet&gt;          
    &lt;h:outputText value="#{classFieldValues[idx]}" /&gt;
  &lt;/rich:columns&gt;
&lt;/rich:dataTable&gt;
</code></pre>

<p>I already have a method on the bean for executing the sort.</p>

<pre><code>public void sort(int column)
</code></pre>

I ended up doing it manually. I adding a support tag to the header text tag, like so.
```
```
<h:outputText value="#{column}">
  <a4j:support event="onclick" action="#{pageDataModel.sort(idx)}"
               eventsQueue="instancesQueue"
               reRender="instanceList,instanceListScroller"/>
</h:outputText>
```
```
To get the ascending/descending arrows, I added a css class.
```
```
<h:outputText value="#{column}" styleClass="#{pageDataModel.getOrderClass(idx)}" >
  <a4j:support event="onclick" action="#{pageDataModel.sort(idx)}"
               eventsQueue="instancesQueue"
               reRender="instanceList,instanceListScroller"/>
</h:outputText>
```
```