我正在使用由某个人创建的管理主题,它在我的dataTables中通过第二列命令所有dada。我试图更改datatable jquery文件,但没有发生。他使用不同的初始化来调用它。
jQuery(document).ready(function() {
App.init(); // initlayout and core plugins
TableAdvanced.init();
});
我不知道要改变什么来禁用排序或通过第一列进行排序..这是主题:http://keenthemes.com/preview/metronic_admin/table_advanced.html也许有人知道答案?
如果要按第一列添加排序,则需要使用类似的内容
$("#sample_1").dataTable({
"aaSorting" : [[0,"desc"]],
"bDestroy":true
});
注意:使用“bDestroy”它将使用具有新属性的数据表替换数据表,因此执行此操作将覆盖dataTable的先前配置。
我认为最好的解决方案是找出在TableAdvanced.init()
中创建数据表的位置
并添加参数aaSorting到它
"aaSorting" : [[0,"desc"]]
这可能工作http://datatables.net/examples/basic_init/table_sorting.html
在metronic管理主题中,文件中有一个文件“../assets/global/scripts/datatable.js”查找“columnDefs”,你会看到下面的代码
"columnDefs": [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column)
'orderable': false,
'targets': [0]
}],
此代码停止第一列可排序。 @Eduardo Quintana提到的上述答案是一种使列可排序的方法。
我现在用这个。任何类型的设置此js文件只是添加另一列,如[ID]返回从您的查询返回没有影响排序desc顺序和搜索选项如何其他列工作正常