自动完成不起作用 - DataTables + Yadcf
Autocomplete doesn't work - DataTables + Yadcf
我用 DataTables 和 Yadcf 插件创建了一个 table。它使用服务器端处理。我在第二列中添加了一个自动完成过滤器,并在服务器响应中添加了 yadcf_data_1 字段,但是在输入时没有任何反应。此外,javascript 控制台中没有任何错误。
你可以看到我的 table here.
$(document).ready(function() {
table = $('#table').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "server_processing.php",
"type": "POST"
},
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.11/i18n/Russian.json"
},
"searching": false,
dom: 'lfrtip<"#table_buttons"B>',
buttons: [
{
text: 'Экспорт в CSV',
action: function ( e, dt, node, config ) {
if(last_data) {
last_data['export'] = 1;
downloadFile("server_processing.php?" + $.param(last_data));
}
}
}
],
"columnDefs": [
{className: "center", "targets": [2, 3, 4, 5, 6, 7, 8]}
]
});
yadcf.init(table, [
{
column_number: 0,
filter_default_label: '--- Все ---'
},
{
column_number: 1,
filter_default_label: 'Введите',
filter_type: "auto_complete",
},
{
column_number: 2,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 3,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 4,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 5,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 6,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 7,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 8,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
]);
从您的初始化代码中删除 searching": false,
,因为它会禁用您的 table
的搜索功能
我用 DataTables 和 Yadcf 插件创建了一个 table。它使用服务器端处理。我在第二列中添加了一个自动完成过滤器,并在服务器响应中添加了 yadcf_data_1 字段,但是在输入时没有任何反应。此外,javascript 控制台中没有任何错误。
你可以看到我的 table here.
$(document).ready(function() {
table = $('#table').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "server_processing.php",
"type": "POST"
},
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.11/i18n/Russian.json"
},
"searching": false,
dom: 'lfrtip<"#table_buttons"B>',
buttons: [
{
text: 'Экспорт в CSV',
action: function ( e, dt, node, config ) {
if(last_data) {
last_data['export'] = 1;
downloadFile("server_processing.php?" + $.param(last_data));
}
}
}
],
"columnDefs": [
{className: "center", "targets": [2, 3, 4, 5, 6, 7, 8]}
]
});
yadcf.init(table, [
{
column_number: 0,
filter_default_label: '--- Все ---'
},
{
column_number: 1,
filter_default_label: 'Введите',
filter_type: "auto_complete",
},
{
column_number: 2,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 3,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 4,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 5,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 6,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 7,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
{
column_number: 8,
filter_type: "range_number",
filter_delay: 500,
filter_default_label: ['от', 'до']
},
]);
从您的初始化代码中删除 searching": false,
,因为它会禁用您的 table