简体   繁体   English

禁用jQuery DataTable中的行重新排序

[英]disabling row reorder in jquery datatable

I am using DataTables Row Reordering Add-on (http://jquery-datatables-row-reordering.googlecode.com/svn/trunk/index.html ) and I want to be able to disable the reordeing in JS. 我正在使用DataTables行重新排序加载项(http://jquery-datatables-row-reordering.googlecode.com/svn/trunk/index.html),并且希望能够禁用JS中的重新排序。 I used code similar to the following code: 我使用了类似于以下代码的代码:

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 });

but it doesn't work (I am still able to drag and drop rows, but since I made the bSort to false, it doesn't save the sort order. I want to disable the drag and drop). 但是它不起作用(我仍然能够拖放行,但是由于我将bSort设置为false,所以它不保存排序顺序。我想禁用拖放功能)。 What can I do? 我能做什么?

After digging a little i found that sortable is used but disabling is slightly different then enabling it. 经过一番挖掘后,我发现使用了sortable,但是禁用与启用它略有不同。

$("tbody", oTable).sortable({"disabled" : true});

$("tbody", oTable).sortable( "enable" );

use: 采用:

$("#your_table_id .ui-sortable" ).sortable("disable"); - to disable -禁用

$("#your_table_id .ui-sortable" ).sortable("enable"); - to enable - 启用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM