我使用的是DataTables版本1.10.16,我目前有一个初始化为这样的数据表:
// Setup the emails datatable
var auto_responders = $('#auto_responders').DataTable({
ajax: {
url: "assets/php/get_auto_responders.php",
dataSrc: ''
},
columns: [
{ data: 'user_first_name', title: 'User Name', createdCell:
function (td, cellData, rowData, row, col) {
$(td).text(cellData + ' ' + rowData['user_last_name']);
}
},
{ data: 'user_last_name', visible: false},
{ data: 'customer_first_name', title: 'Customer Name', createdCell:
function (td, cellData, rowData, row, col) {
$(td).text(cellData + ' ' + rowData['customer_last_name']);
}
},
{ data: 'customer_last_name', visible: false},
{ data: 'email', title: 'Email', createdCell:
function (td, cellData, rowData, row, col) {
$(td).html('<a href="mailto:' + cellData + '">' + cellData + '</a>');
}
},
{ data: 'customer_id', searchable: false, visible: false },
{ data: 'date_entered', title: 'Date Entered' },
{ data: 'title', title: 'Auto-Responder' },
{ data: 'queued_ids', title: 'Upcoming Responders', searchable: false, createdCell:
function (td, cellData, rowData, row, col) {
if (!cellData) {
$(td).html('<span class="text-danger text-center d-block">No Automatic Responders Queued</span>');
} else {
$(td).html('<button type="button" class="btn btn-block btn-outline-success queued_auto_responders" data-queued-ids="' + cellData + '" data-toggle="modal" data-target="#modal_queued_responders">View Queued Automatic Responders</button>');
}
}
}
]
});可以看出,我在显示前两列(用户的名字和姓氏),然后是下两列(客户的名字和姓氏),但我将各自的姓氏列的可见性设置为false。
要为网页上的人员创建下拉过滤器,以便快速查看特定用户的所有行,我有以下代码:
auto_responders.columns([0, 1]).search(filter).draw();其中,值filter等于用户的全名。我的问题是,我认为通过指定前两列,它会尝试将筛选器中的名称与用户的名字和姓氏相匹配,但当我尝试使用该代码时,没有返回任何行。根据第一列和第二列都至少包含一部分筛选器的位置,如何才能返回到返回行的位置?
发布于 2018-12-20 22:06:36
https://stackoverflow.com/questions/53858964
复制相似问题