Datatable initial Filter

Datatable initial Filter

rit_netsysrit_netsys Posts: 5Questions: 2Answers: 0

Hello,
I am trying to use Datatable. Everything is working perfectly. But somehow I am not able to manage initial Filter. I want my Datatable should show (on load) only values according to a given value. Here is my code -

$(document).ready(function () {
$('#csv1').removeAttr('width').dataTable({
"oSearch": {"sSearch": "TEST1_T"},
"search": {"search": "TEST1_T"},

"ordering": true,
"language": {
"zeroRecords": "No records to display"
},
//ajax: 'Output/logcheck.txt',
fixedHeader: true,
//scrollY: 300,
//scrollX: true,
//scrollCollapse: true,
deferRender: true,
scroller: true,
stateSave: true,
processing: 'Loading...',
autowidth: false,
responsive: false,
orderClasses: false,
columnDefs: [
{ width: 100, targets: 0 }
],
fixedColumns: true
}).yadcf([
{ column_number: 0 },
{ column_number: 1 },
{ column_number: 2 },
{ column_number: 3},
{ column_number: 4 },
{ column_number: 5 },
{ column_number: 6 },
{ column_number: 7 },
{ column_number: 8 },
{ column_number: 9 },
{ column_number: 10 },
{ column_number: 11 },
{ column_number: 12 },
{ column_number: 13 },
{ column_number: 14 },
{ column_number: 15 },
{ column_number: 16 },
{ column_number: 17 }
]);
});

Need help on this. I am getting Out put like attached file.

But I need Output like this -

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,310Questions: 26Answers: 4,948
    Answer ✓

    Your code works here:
    http://live.datatables.net/wuvebeji/1/edit

    You only need one of oSearch or search. The second will override the first since they are the same option.

    Anytime something in Javascript, like Datatables, doesn't behave as expected I first look at the console to see if there are any errors that stop Datatables from completing the initialization.

    If this doens't help then please post a link to your page or a test case replicating the issue. You can update my example if you want. Without seeing the issue and your data it would be hard to troubleshoot.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • rit_netsysrit_netsys Posts: 5Questions: 2Answers: 0

    Thanks kthorngren for the answer. Is there any way to pass Variable as Search parameter?

  • kthorngrenkthorngren Posts: 21,310Questions: 26Answers: 4,948
    Answer ✓

    Is there any way to pass Variable as Search parameter?

    Yes, see the updated example.
    http://live.datatables.net/wuvebeji/2/edit

    Kevin

This discussion has been closed.