Get rows after sorting

Get rows after sorting

adrian22adrian22 Posts: 6Questions: 3Answers: 0

Hi,

Great plugin!! But I have a problem with getting the right data back after sorting.

        datatable.data().each(function(index, value) {
            console.log($(index[0]).prop('id') + ' ' + value);
        });

Gives me one row and the first id attrbute of node. The problem rises when I sort the list.
The loop gives me exactly the same data, even ordering/sorting have changed.

Please help!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,823Questions: 1Answers: 10,129 Site admin
    Answer ✓

    data() will return an array of the data, in the original read order.

    If you want the data in the current order use rows().data() (see also rows()) with a selector-modifier - e.g. table.rows( { order: 'current' } ).data().

    Allan

  • adrian22adrian22 Posts: 6Questions: 3Answers: 0

    Thanks! Using api this is my solution.

    ,"drawCallback": function () {
    pl.adata = this.api()
    pl.afdata = pl.adata.rows({'order':'applied', 'search':'applied'}).data();
    }

This discussion has been closed.