Datat Table Fix Column
Datat Table Fix Column
hi
datatable in server side mode sort an search not working after enable fixcolumn column .
please help me.
Table = $('#tbl').DataTable({
"processing": true,
dom: 'Blfrtip',
"scrollY": 200,
"scrollX": true,
fixedHeader: true,
"fixedColumns": {
"leftColumns": 2
},
orderable: true,
"serverSide": true, // for process server side
"filter": true, // this is for disable filter (search box)
//"orderMulti": true, // for disable multiple column at once
"formatNumber": function (toFormat) {
return toFormat.toString().replace(
/\B(?=(\d{3})+(?!\d))/g, "'"
);
},
"ajax": {
"url": '@Url.Action("Loaddata", "Sale")',
"type": "POST",
"datatype": "json",
"data": {
'Status': 1
}
},
"initComplete":LisIinitComplete,
"lengthMenu": [10, 25, 50, 75, 100],
"Search": "Quick Search:",
"columns": [
{ "data": "ID", "name": "ID", "autoWidth": true, "className": "d-none" },
{ "data": "No", "name": "ProformaNo", "autoWidth": true },
{ "data": "CustomerID", "name": "CustomerID", "autoWidth": true, "className": "d-none" },
{ "data": "CustomerCode", "name": "CustomerCode", "autoWidth": true, "className": "d-none"},
{ "data": "CustomerName", "name": "CustomerName", "autoWidth": true, "className": "d-none"},
{ "data": "CustomerFamily", "name": "CustomerFamily", "autoWidth": true, "className": "d-none"},
{ "data": "RejectDescription", "name": "RejectDescription", "autoWidth": true }
],
buttons: [
{
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
},
'copy', 'excel', 'csv',
{
extend: 'print',
text: 'Print',
exportOptions: {
modifier: {
selected: null
}
}
}
]
});
Answers
You have
"filter": true, // this is for disable filter (search box)
. This not only disables the search box but also the searching function. See thesearching
docs. You can remove the search input by using thedom
option.I'm not sure about sorting, don't see anything obvious. We will need a link to you page or a test case replicating the issue in order to help debug. What happens when you try to sort? Do you get errors in the browser's console? Do the sort arrows change? Is there a request sent to the server for the sorted data? What is the server's JSON response?
Also note that the FixedHeader docs state this:
Using FixedHeader and FixColumns (and scrolling features) are not compatible.
Kevin