Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82710

Filter Data in a single column

$
0
0

Hello
Im using datatables to display the data. There are various columns that are part of the datatables, however i would like to show the row only if the value is set to "ABC" for a specific column.
Additionally there is also an export to Excel option provided which should be exporting all the data and not just the filtered data
After looking at the api found there is .filter option, but it doesnt seem to work. (Can still see all the data)

Code snippet:
var table = $('.tableContent').DataTable({
"autoWidth": false,
"pageLength": 50,
dom : 'lBfrtip',
buttons : [ {
extend : 'excel',
text : 'Export to Excel'
} ],
"columnDefs" : [{
"targets" : [ 0, 1, 2, 5, 8, 9, 10, 11, 12, 17, 18 ],
"visible" : true,
"searchable" : true
}, {
"targets" : [ 3, 4, 6, 7, 13, 14, 15, 16, 19, 20, 21 ],
"visible" : false,
"searchable" : false
}]
});

    var filteredData = table
        .column(17)
        .data()
        .filter(function(value, index) {
            return value.toLowerCase() == 'abc' ? true : false;
    });

Any help to resolve the above will be greatly appreciated.


Viewing all articles
Browse latest Browse all 82710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>