我正在使用DataTables Row Reordering Add-on(http://jquery-datatables-row-reordering.googlecode.com/svn/trunk/index.html),我希望能够在JS中禁用重新排序。我使用的代码类似于以下代码:
if ($(this).attr("checked")) {
$("#" + parameters.TableId).dataTable(
{
"bDestroy": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": true
}).rowReordering({ sURL: parameters.sURL, iIndexColumn: parameters.iIndexColumn });
} else {
$("#" + parameters.TableId).dataTable(
{
"bDestroy": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": true
});//.rowReordering({ sURL: parameters.sURL, iIndexColumn: parameters.iIndexColumn });
但它不起作用(我仍然可以拖放行,但由于我将bSort设置为false,它不保存排序顺序。我想禁用拖放)。我该怎么办?
答案 0 :(得分:0)
在挖了一点之后,我发现使用了sortable,但禁用与启用它稍有不同。
$("tbody", oTable).sortable({"disabled" : true});
$("tbody", oTable).sortable( "enable" );
答案 1 :(得分:-1)
使用:
$("#your_table_id .ui-sortable" ).sortable("disable");
- 禁用
$("#your_table_id .ui-sortable" ).sortable("enable");
- 启用