title: Disabling ability to change the sort-order of a sorted OpenFaces Datatable
body: <p>On a JSF page for viewing data, I've an OpenFaces datatable with sorting and column reordering enabled saved to appropriate backing bean properties (via: sortColumnId, sortAscending, columnsOrder attributes on the o:dataTable element). On a corresponding inline edit page (where through custom code individual lines of the table can be saved one at a time by the user), the columnsOrder of the datatable is linked to the same property so the columns appear in the same order as on the view page, but the o:columnReordering element is not present in the datatable to prevent column reordering on the edit page. This is required because the AJAX call initiated by moving column fails, due to an error in the partial response XML, to update the table. (There are other requirements too which mean the table should be prevented from being updated via AJAX on the edit page.)</p>
  
  <p>I want to be able to have the datatable on the edit page sorted in the same order as on the view page but with sorting disabled too. However, this doesn't seem possible in OpenFaces. I've linked the datable on the edit page to the same backing bean properties, but for the sorted column to display as sorted, the o:column tag needs to have a sortingExpression attribute. When that attribute is added to the column, that column becomes sortable by the user being able to click on the column header. When not added, the column is not sortable by the user but the table is also not sorted by that column even though it's specified in the backing bean property as being the column to sort by.</p>
  
  <p>Using JavaScript run by JQuery once the DOM has been created, I've tried overwriting the function called by the click event on the 'th' element of the OpenFaces column header but after calling the function, the AJAX call to sort and refresh the table is still called. The code used is:</p>
  
  <p>in Edit.xhtml:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $('#doorNumberColumnHeader').parents('th').onclick = null;
          $('#doorNumberColumnHeader').parents('th').click(function(event) {
              alert("Preventing AJAX call");
  
              if (event) {
                  event.preventDefault ? event.preventDefault() : event.returnValue = false;
              }
  
              return false;
            });
        });
  &lt;/script&gt;
  </code></pre>
  
  <p>within OpenFaces datatable of Edit.xthml:</p>
  
  <pre><code>&lt;o:column id="doorNumberColumn" sortingExpression="#{submission.doorNum}" fixed="true" width="50px"&gt;
      &lt;f:facet name="header"&gt;
          &lt;h:outputText value="#{bundle.SubmissionDoorNumber}" id="doorNumberColumnHeader"/&gt;
      &lt;/f:facet&gt;
      &lt;h:outputText value="#{submission.doorNum}"/&gt;
  &lt;/o:column&gt;
  </code></pre>
  
  <p>Is there a better way of attempting to prevent the AJAX call to stop the user being able to change the sort order of the table?</p>
  
  <p>Thanks.</p>