rea*_*ebo 1 javascript datatable jquery
我正在成功使用此代码
function refreshDataTable() {
// The table is made sortable
$('#order_proposal_table').DataTable({
'destroy' : true, // see http://datatables.net/manual/tech-notes/3#destroy - 2nd example
'paging' : false,
'scrollCollapse' : true,
'scrollY' : '65vh',
'fixedHeader' : true,
'dom' : 'rt',
});
}
Run Code Online (Sandbox Code Playgroud)
然后我试图在9列中的2列中启用搜索.
所以我改变了
'dom' : 'rt',
Run Code Online (Sandbox Code Playgroud)
成
'dom' : 'frt',
Run Code Online (Sandbox Code Playgroud)
显示查找输入框.这可行,但它搜索每一列,但我只需要搜索到2列.
因此,我正在尝试按照此官方指南有选择地禁用过滤,并添加columns定义
结果代码:
function refreshDataTable() {
// The table is made sortable
$('#order_proposal_table').DataTable({
'destroy' : true, // see http://datatables.net/manual/tech-notes/3#destroy - 2nd example
'paging' : false,
'scrollCollapse' : true,
'scrollY' : '65vh',
'fixedHeader' : true,
'dom' : 'frt',
'columns' : [ // see https://datatables.net/reference/option/columns.searchable
{ 'searchable': false },
{ 'searchable': false },
null, // product code
null, // description
{ 'searchable': false }
]
});
}
Run Code Online (Sandbox Code Playgroud)
问题是我从数据表javascript中出现了javscript错误
TypeError:col未定义
删除columns代码有效.
我究竟做错了什么?
rea*_*ebo 10
我决定使用该columnsDef选项.
以下代码禁用了对指定列的搜索.正是我想要的.
'columnDefs' : [ // see https://datatables.net/reference/option/columns.searchable
{
'searchable' : false,
'targets' : [0,1,4,5,6,7,8,9]
},
]
Run Code Online (Sandbox Code Playgroud)
您是否尝试过为其余 4 列传递 null 而不是仅指定前 5 列?所以:
'columns': [
{ 'searchable': false },
{ 'searchable': false },
null,
null,
{ 'searchable': false },
null,
null,
null,
null
]
Run Code Online (Sandbox Code Playgroud)
我会将此作为评论发布,但我无法包含该示例。
| 归档时间: |
|
| 查看次数: |
11314 次 |
| 最近记录: |