Enabling several rows selection with shift

Enabling several rows selection with shift

valdezrvaldezr Posts: 49Questions: 0Answers: 0
edited April 2009 in General
How can be possible to select several records in the same page with the use of "Shift" key so that you make a click on the first row and another click+shift in the last row and all the rows in the interval get selected?

Thanks in advance.

Replies

  • allanallan Posts: 63,113Questions: 1Answers: 10,397 Site admin
    edited April 2009
    Hi,

    This demo shows how you can do multiple user-selectable rows: http://datatables.net/examples/example_select_row.html . Changing it to select multiple rows should be fairly trivial using the e.shift parameter.

    Hope this helps,
    Allan
  • valdezrvaldezr Posts: 49Questions: 0Answers: 0
    Excuse me for my novice knowledge but it is not trivial for me, where is the e.shift parameter and how I could use it.

    Could you provide me an example?

    Thanks a lot.
  • allanallan Posts: 63,113Questions: 1Answers: 10,397 Site admin
    Hi valdezr,

    The e.shift parameter is part of the event object that is passed into the click event handling function (in my example "$('#example tr').click( function() {" - this would be modified to "$('#example tr').click( function(e) {" ). I'll not write the code for you directly (unless of course you wish to contract me :-) ), but hopefully this will point you in the right direction! A google search for "javascript detect shift key" will also yield plenty of results.

    Hope this helps,
    Allan
  • rgvcorleyrgvcorley Posts: 29Questions: 0Answers: 0
    Just for reference for anyone else trying to achieve this, I couldn't get it to work with e.shift however it did work with e.shiftKey
This discussion has been closed.