我正在应用列搜索但是第一次针对每列显示文本框但是当我对任何列文本框排序时,搜索未启用也会消失。只是列搜索无法正常工作
var table = "";
var fillDataTable = function(sitesList) {
table = $("#locationListTable").DataTable({
"aaData": sitesList,
'dom': 'lfrti',
'scrollX': true,
'scrollY': 300,
'scroller': true,
'deferRender': true,
'paging': false,
'bSort': true,
'colReorder': true,
'bSortCellsTop': false,
'bAutoWidth': true,
"bPaginate": false,
"bInfo": false,
'destroy': true,
"fnRowCallback": function(nRow, aData) {
// $('td:eq(0)', nRow).html('<a href="' + path.AppPath + 'Membership/Member/Detail/' + aData.memberId + '">' + aData.lastName + '</a>');
// $('td:eq(0)', nRow).addClass('member-' + aData.status);
// $('td:eq(1)', nRow).html('<a href="' + path.AppPath + 'Membership/Member/Detail/' + aData.memberId + '">' + aData.firstName + '</a>');
// if (aData.status === "Active") {
// $('td:eq(5)', nRow).html('<span class="text-success">' + aData.status + '</span>');
// }
// if (aData.status === "Inactive") {
// $('td:eq(5)', nRow).html('<span class="text-danger">' + aData.status + '</span>');
// }
},
"aoColumns": [{
data: 'company.name',
defaultContent: 'N/A',
'sWidth': '10%'
}, {
data: 'city',
defaultContent: 'N/A',
'sWidth': '12%'
}, {
data: 'name',
defaultContent: 'N/A',
'sWidth': '5%'
}, {
data: 'phoneNumber',
defaultContent: 'N/A',
'sWidth': '10%'
}, {
data: 'state',
defaultContent: 'N/A',
'sWidth': '10%'
}, {
data: 'zip',
defaultContent: 'N/A',
'sWidth': '10%'
}]
});
new $.fn.dataTable.ColReorder(table, {
iFixedColumnsRight: 1
});
//jquery datatable events
};
fillDataTable($scope.sitesList);
table.on('column-reorder', function(e, settings, details) {});
$('#locationListTable tfoot th').each(function() {
debugger
var title = $('#locationListTable thead th').eq($(this).index()).text();
$(this).html('<input type="text" class="form-control" placeholder="search"' + title + ' />')
});
table.columns().every(function() {
debugger
console.log(this.data);
var dataTableColumn = this;
$(this.footer()).find('input').on('keyup change', function() {
debugger
dataTableColumn.search(this.value).draw();
});
});