Reset to initial state and do sort by current column

Reset to initial state and do sort by current column

FedarFedar Posts: 6Questions: 2Answers: 0

I have a table. But I want to sort a dataset from left to right. I do not want take into account state of the data of the previous sorting. How can i do it?

        var table = $('.total');
        var sTable = table.DataTable({
            searching: false,
            bLengthChange: false,
            bInfo: false,
            paging: false,
        });

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    something like this?

    http://live.datatables.net/seqatati/1/edit

    $(document).ready(function() {
        $('#example').DataTable( {
          "order": [[ 0, "asc" ],
                    [1,"asc"],
                    [2, "asc"],
                    [3,"asc"],
                    [4,"asc"],
                   [5,"asc"]],
          dom:"t",
          paging:false
          
        } );
    } );
    
  • FedarFedar Posts: 6Questions: 2Answers: 0

    No. As if understand right, next sorting is based on current state of the dataset. Ex. If I have two row with data Alex, 20 and Anthony, 20. After sorting by Name Alex will be in first place, and after sorting by Age and again by Name - Alex will be in second place

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    That's is not what is happening in my example. Added AAlex and AAnthony. it does not matter what you click on, when you click on name, they end up in the right order.

    http://live.datatables.net/seqatati/2/edit

  • FedarFedar Posts: 6Questions: 2Answers: 0

    http://live.datatables.net/jeyozive/1/edit
    Initial state: 1. AAlex, 2. AAnthony, 3. Ashton Cox
    Click Name, next click Age.
    Result: 1. AAnthony, 2. Ashton Cox, 3. AAlex,

    I think for next sorting a plugin get previous state of the data (Name: desc). But i want to reset state and do sorting.

  • FedarFedar Posts: 6Questions: 2Answers: 0

    Thank you, bindrid. Your help is very important for me.
    I found a solution:
    https://datatables.net/forums/discussion/42635/how-process-a-sorting-if-x-y#latest

This discussion has been closed.