1

I am using the jQuery DataTables plug-in in my application. I need to select the multiple rows in a jQuery datatable using the mouse drag option. How is it possible?

karel
  • 5,489
  • 46
  • 45
  • 50
David Ferry
  • 283
  • 1
  • 4
  • 14

1 Answers1

3

Use jQuery-UI selectable and code similar to the following:

$( "#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' );
         });
     }
  });

I use 'distance: 10' because I found that otherwise my mousedown handler for the table wouldn't get events - this may not be important for you.

balrob
  • 585
  • 6
  • 7