Messing with selectable rows: restrict selection to certain columns

Messing with selectable rows: restrict selection to certain columns

nm_alexnm_alex Posts: 26Questions: 0Answers: 0
edited October 2010 in General
Dear all!

There is this example for user selectable rows: http://datatables.net/examples/api/select_row.html
I changed it so it only select one row (yes I know, there is an example for this, too).

So, basically, the selection works by binding the click to the selection function:
[code]
$('#example tr').click( function() {
// selection stuff here, $(this) is the row
});
[/code]

How do I restrict the selection to the first three columns of the table?

I tried something like:
[code]
$('#example tbody tr td:lt(7)').live('click', function() {
var nRow = $(this).parent();
});
[/code]

But I don't get it to work, as my bindig only applies to the first row, the other don't get the binding.

Of course I can just iterate over all columns, call the bind function for each row once.

However, I wonder if this could be done using a propper jQuery selector.

Any ideas?

best ergards, Alex
This discussion has been closed.