jQuery "selectable" and DataTables - how?

jQuery "selectable" and DataTables - how?

datatablesn00bdatatablesn00b Posts: 7Questions: 0Answers: 0
edited June 2010 in General
Re,

I am using the following code:

[code]
$('#test tbody tr').selectable({
selected: function(event, ui)
{
$(this).addClass('row_selected');
}
});
[/code]

It only selects 1 item. Has anyone done this before? What's the trick? Appears as if the mouse select within the table works on the X axis only.

Replies

  • datatablesn00bdatatablesn00b Posts: 7Questions: 0Answers: 0
    edited June 2010
    OK, once again I am answering my own question :))

    [code]
    $('#test').selectable
    ({
    stop: function(event, ui)
    {
    $(this).find("tr").each(function()
    {
    if($(this).hasClass('ui-selected')) $(this).addClass('row_selected');
    else $(this).removeClass('row_selected');
    })
    alert ("You selected :"+$('#test').find('.row_selected').size()+" items.")
    }
    });
    [/code]

    This code will select rows using mouse & jQuery UI "selectable". Hope this is useful for someone.

    Cheers.
  • giorgio79giorgio79 Posts: 43Questions: 0Answers: 0
    Awesome, I was just looking for a way to select multiple rows by dragging the mouse.

    Would be cool to put it in the examples.
This discussion has been closed.