DataTables logo DataTables

via Ad Packs
How to sort a Transaction record?
  • zhenguangzhenguang
    Posts: 2
    Hi,

    I'd like to sort a ledger such that my table is in

    0
    1
    2
    3
    4
    5

    I'd like the 1st page to be
    3
    4
    5

    And the second page to be
    0
    1
    2

    I've tried but i could only be able to get
    page 1,
    5
    4
    3

    and second page
    2
    1
    0

    I'd like to use Datatable to sort the transaction record, such that when they click next, they will see the history log
    $('#example').dataTable( {
            "aaSorting": [[ 0, "desc" ]],
     		"bPaginate": true,	 
    });	
    

    Please advise!

    Thanks in a million
  • allanallan
    Posts: 15,851
    You would need to create a custom sorting function ( http://datatables.net/development/sorting ) to implementing sorting that is discontinuous such as this.

    Allan
  • zhenguangzhenguang
    Posts: 2
    I need to reverse the table rows appear from a aaSorting desc orders... any idea how can i reverse the current 'view' dataset?
  • allanallan
    Posts: 15,851
    There is no concept of that in DataTables core at the mount - the sort applies to the full data set, not a subset. If you do want to sort only a subset, then you would need to create a sorting plug-in. Its not something I've done before I'm afraid (a subset sorting plug-in!) but it should be possible with all the information available. It might involve a fairly good understand of how DataTables sorts data - specifically the aiDisplay and aiDisplayMaster arrays. I'd suggest looking at the source for _fnSort in DataTables.

    Allan
This discussion has been closed.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion