Columns get mixed up when sorting them after reordering with ColReorder

Columns get mixed up when sorting them after reordering with ColReorder

systembotsystembot Posts: 4Questions: 0Answers: 0
edited January 2012 in Bug reports
Dear Allan,

if I am right this seems to be a bug of the ColReorder plugin. Sorting jars with reordering. When I reorder the columns using ColReorder and want to sort a reordered column, another column, which is now at the position of the reordered column before reordering it, get sorted. The indices get mixed up although I assigned names to the columns via sName and mDataProp. I suppose this has already been tested against but since I can not figure out the error in my server-side processed implementation of the sorting functionality I assume this might be a bug since I get correct results of the reordering and sorting after reloading the page.

Best regards,
systembot

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    This example shows that it should work just fine: http://datatables.net/release-datatables/extras/ColReorder/server_side.html . As you are aware you need to convert the index given to the server-side processing script to the column you want to sort on. How are you doing that?

    Allan
  • systembotsystembot Posts: 4Questions: 0Answers: 0
    edited February 2012
    Dear Allan,

    you are completely right. It was not a bug, but the wrong conversion of the index of the column being sorted on to the column position after the reordering. I used the 'mDataProp' column property in the jQuery script and the 'mDataProp_x' GET-parameter in the server-side processing script for the conversion.

    Here is the simple way I did the conversion (cf. the condition of the switch-statement):

    [code]
    for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) { // iterate for each column to be sorted
    if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") { // make sure the column is sortable
    switch ($_GET['mDataProp_'.intval($_GET['iSortCol_'.$i])]) { // determine the position of the column to be sorted
    case '' : ...; break;
    case ...
    ...
    }
    }
    }
    [/code]

    Thank you very much for the support and very quick response, Allan.
  • cbattarelcbattarel Posts: 14Questions: 0Answers: 0
    thanks for this sample... Allan, maybe it would be easier if the link you mention contains a sample serverside-processing with the code for serverside reorder; here is mine :
    [code]
    /*
    * Ordering
    */
    if ( isset( $_REQUEST['iSortCol_0'] ) )
    {
    $sOrder = "ORDER BY ";
    for ( $i=0 ; $i
This discussion has been closed.