table.column(0).data().toArray(); gives all records into array even when filter is applied

table.column(0).data().toArray(); gives all records into array even when filter is applied

rahulsonawanerahulsonawane Posts: 6Questions: 2Answers: 0
edited July 2019 in Free community support

My DataTable has total 10 rows in it, after applyinng filter it has only 3 rows.
Column 0 is OfferID's of different offers.

Now when I am doing ,
var table = $('#MyTable').DataTable();
var arrayOfferID = table.column(0).data().toArray();

arrayOfferID contains all 10 OfferID from all records even when filter is applied, how to get only 3 filtered records offerID in array

This question has an accepted answers - jump to answer

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi rahulsonawane,

    You need to add one more piece of information to your .column() method - {search:'applied'}

    It should read table.column(0,{search:'applied'}).data().toArray()

    An example of this can be found here

    Hope this helps,
    Sandy

  • rahulsonawanerahulsonawane Posts: 6Questions: 2Answers: 0

    Thank you very much Sandy, that solved my issue

This discussion has been closed.