title: How to reorder columns in datatable with drag and drop Primefaces
body: <p>I use primefaces version 5.2 and jsf version 2.2.6.</p>
  
  <p>I have a datatable and I want to reorder the columns with drag and drop. Besides I have also the column toggle functionality, with which I can hide columns. The reordering and hiding of columns are saved into the database.</p>
  
  <p>For me it is no problem if on specific positions are hidden columns, I can drop the dragged column after or before the position of the hidden ones.</p>
  
  <p>I use the following ajax event:</p>
  
  <pre><code>&lt;p:ajax event="colReorder" listener="#{transactionsPage.onColumnReorder}"/&gt;
  </code></pre>
  
  <p>and the method signature looks like this:</p>
  
  <pre><code>public void onColumnReorder(AjaxBehaviorEvent event)
  </code></pre>
  
  <p>If I could have used ReorderEvent to get the fromIndex and toIndex, it would have been very easy to deal with this situation, but unfortunately this event can be used only for dragging and dropping rows and not columns.</p>
  
  <p>Is there a way to find out these indexes? Even only the fromIndex could be enough.</p>