Individual Search Columns not working in Fixed Columns
Individual Search Columns not working in Fixed Columns
![roipatrick](https://secure.gravatar.com/avatar/4415eb3287a99b4e84743d2e514f85d8/?default=https%3A%2F%2Fvanillicon.com%2F4415eb3287a99b4e84743d2e514f85d8_200.png&rating=g&size=120)
I have a table and applied a Fixed column on it fixing the first two columns which was successful on my end. In Addition to this, I also applied individual search columns but it seems to work only on the not fixed columns. It does not work on the fixed columns. If you need to see how I copied and reconstructed the JS here's the code.
$(document).ready(function() { $('#example tfoot th').each( function () { var title = $('#example thead th').eq( $(this).index() ).text(); $(this).html( '' ); } ); var table = $('#example').DataTable({ setTimeout: "50", scrollY: "350px", scrollX: true, scrollCollapse: true, paging: false, heightMatch: "auto", columnFilter: true, fixedColumns: { leftColumns: 2 }, }); table.columns().every( function () { var that = this; $( 'input', this.footer() ).on( 'keyup change', function () { that .search( this.value ) .draw(); } ); } ); });<style type="text/css">
/* Ensure that the demo table scrolls */
th, td { white-space: nowrap; }
div.dataTables_wrapper {
width: 1210px;
margin: 0 0 0 0;
}
</style>
Note: To explain it more clear, I have let's say 6 columns and the first two columns (columns 1,2) are freezed/fixed. The indivudual column search works on 3,4,5,6 but not it 1 and 2.
Answers
Seems like its a problem with the combination of scrollx and fixheader being enabled.
Kevin
Yes, more specifically, I think it sounds like it might be an event issue. The event isn't being listened for on the cloned fixed tables. Can you link to the page please?
Allan
.
hi allan,
I am also facing the same problem. I want to freeze the first two columns but when I freeze it, individual search doesn't work.
Following is my code.
customerTable = $('#customerTable').DataTable({
"responsive": true,
"paging": true,
"ordering": true,
"info": true,
"searching": true,
"serverSide": true,
"filter": true,
"orderCellsTop": true,
"order": [[0, "desc"]],
"scrollX": true,
"scrollCollapse": true,
fixedColumns: {
leftColumns: 2,
rightColumns: 1
},
"ajax": {
"url": "/Customer/LoadCustomers",
"type": "POST",
"dataType": "json",
"data": function (d) {
d.FirstCustomField = inActive;
d.SecondCustomField = isPotential;
d.ThirdCustomField = customerLookUp;
},
"complete": function () {
DropdownMenuWidth();
DropDownMenuPostion();
}
},
"language": {
"search": "",
"searchPlaceholder": "Search..."
},
'columnDefs': [
{
"aTargets": [7], //indexes of whatever columns you need to format
"mRender": function (data, type, full) {
if (data) {
var mDate = moment(data);
return (mDate && mDate.isValid()) ? mDate.format("L") : "";
}
return "";
}
}
],
initComplete: function () {
debugger;
var api = this.api();
api.columns().every(function (index) {
var that = this;
$('#customerTable thead tr:eq(1) th:eq(' + index + ') input').on('keyup change', function () {
debugger;
//$('input', this.footer()).on('keyup change', function () {
if (that.search() !== this.value) {
that.search(this.value)
.draw();
}
});
});
},
"columns": [
{ "data": "LastName" },
{ "data": "FirstName" },
{ "data": "Phone1" },
{ "data": "Addr1" },
{ "data": "Addr2" },
{ "data": "City" },
{ "data": "State" },
{ "data": "InactiveDate" },
{ "data": "EmailAddr" },
{ "data": "ZipCode" },
{ "data": "Notes" },
{ "data": "NSF" },
{ "data": "ServiceNotes" },
{ "data": "BillToLastName" },
{ "data": "BillToFirstName" },
{ "data": "BillToAddr1" },
{ "data": "BillToAddr2" },
{ "data": "BillToCity" },
{ "data": "BillToZipCode" },
{ "data": "BillToFax" },
{
"data": "Discount",
render: function (data, type, full, meta) {
return "
";
}
},
{
"render": function (data, type, full, meta) {
This example of using column searches with FixedColumns should help:
https://datatables.net/extensions/fixedcolumns/examples/styling/col_filter.html
Kevin
ok thanks.