如何使用鼠标拖动选项在jQuery数据表中选择多行

How to select the multiple rows in jQuery datatable using the mouse drag option

本文关键字:数据表 选择 jQuery 何使用 鼠标 拖动 选项      更新时间:2023-09-26

我在我的应用程序中使用jQuery数据表插件。我需要使用鼠标拖动选项选择jQuery数据表中的多行。这怎么可能?

使用jQuery-UI selectable,代码类似如下:

$( "#yourTable" ).selectable(
  {
     distance: 10,
     stop: function()
     {
       $( this ).find( "tr" ).each(
         function () {
           if ( $( this ).hasClass( 'ui-selected' ) )
             $( this ).addClass( 'row-selected' );
           else
             $( this ).removeClass( 'row-selected' );
         });
     }
  });

我使用'distance: 10',因为我发现,否则我的mousedown处理程序表不会得到事件-这可能不重要,对你。