Dealing with links in table with Select extension enabled

Dealing with links in table with Select extension enabled

jLinuxjLinux Posts: 981Questions: 73Answers: 75

I have a DataTables instance setup for something at work, and it has a few DT extensions enabled, one of which is the awesome Select extension, setup to allow multi row selection.

One of the columns contains an HTML link (which will execute some JS when clicked, as opposed to navigate the user away from the page). I'm trying to get it setup so viewers can click on the links, and not have it select the row in the table. The row will only be selected when the row "background" is clicked.

I setup a quick example here. When a name in the first column is clicked, some jQuery gets executed to update a span above the table. You will notice that when you click a name, the row gets selected as well, and thats what i'm trying to avoid.

So, is there an easy way to do this? If so, that would be great!

Thanks!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin

    The way to handle this is with the user-select event. That allows you to cancel the selection by returning false from the event handler. The original event information is passed in so you can check if it was a a element that was clicked on: http://live.datatables.net/tefamuro/3/edit .

    Allan

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Perfect! Thanks Allan.

    Hope you're doin well, its been a minute since I was on these forums last, haha

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Answer ✓

    Good to see you back and with another good question :-). The user-select event hasn't long been implemented actually, and it was designed for exactly this sort of use case.

    Allan

This discussion has been closed.