javascript - Datatable : Adding callback function on filter and get filtered data array -


i'm using datatable 1.10.4.

i'm sending data array table populate table, initialization follows:

table = $('#dashboard-user-list-table').datatable({     "data":window.myapp.model.usermodel.getusers(), //sourced js array      "idisplaylength": 4,     ---     ---  }); 

i want add onfilter callback function , filtered data array , stuff.

even without callback function , there way filtered data array?. (basically need array passed sourced data visible on page)

does datatables plugin allow me this? if so, haven't found in documentation intuitive.

can please suggest me how it?

refer jsfiddle

i understand want filtered data array when perform search.
if so, try this.

var table = $('#dashboard-user-list-table').datatable({     ---     ---  }); $('##dashboard-user-list-table').on('search.dt', function () {     var api = table.api();     //uppercase used case insensitive search     var searchterm = api.search().touppercase();      var filtereddata = api.data()         .filter(function (value, index) {             return value.tostring().touppercase().indexof(searchterm) !== -1;         }).toarray();     console.log(filtereddata); }); 

working fiddle: http://jsfiddle.net/codeandcloud/a8b3ttf7/

disclaimer: there might simpler way. not of datatables.net expert


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -