从DataTable中的不可订购列中删除类

时间:2015-11-13 09:03:40

标签: jquery datatables

我使用html5 data-orderable属性来设置巫婆列在我的表格中是不可订购的。

所以我有这个表的模板:

<table>
    <th data-orderable='false'></th>
    <th></th>
    <th></th>
</table>

但是当我的表格呈现时,我会在 中得到 class =&#34; sorting_asc&#34; ,如下所示:

<th data-orderable="false" class="sorting_asc"> ... </th>

订购已停用,但我需要阻止该类出现。 如何禁用添加该类?

更新:

我还尝试在列定义中设置orderable: false,但我得到了相同的行为。创造了小提琴的例子:

http://jsfiddle.net/freshbm/128ez26x/23/

1 个答案:

答案 0 :(得分:2)

默认情况下,您的第一列设置为已排序。

尝试按第二列添加order: [[ 1, "asc" ]],到默认顺序。

$('#exampleTable').DataTable({
    destroy: true,
    bLengthChange: false,
    bInfo: false,
    order: [[1, "asc"]],
    columns: [
        {
           data: null, className: "control center",
           defaultContent: '<img src="http://i.imgur.com/SD7Dz.png">',
           orderable: false
        },
        {data: "vendor", className: 'vendor'},
        {data: "year", className: 'year'},
        {data: "status", className: 'status'}
    ],
    data: newRowData
});
相关问题