How can I move the selection of a record, when checking a "permanent" checkbox in a row?

How can I move the selection of a record, when checking a "permanent" checkbox in a row?

belldrbelldr Posts: 12Questions: 4Answers: 0

I am displaying 4 rows, and the first one is selected. I click a "permanent" checkbox in the third row. I want the third row to end up selected (so that the Edit button will then pop up a bubble for that row). The third row should end up with the "selected" class highlighting. Clicking the box in the third row updates the correct record in the database just fine. It clears the "selected" status on row 1, just fine. But how do I make row 3 "selected"? I have looked at all the events I can find (row callbacks, for example), but after the last callback, "something" generally clears anything I have tried to do in various events. Any ideas would be most welcome. Thank you.

This question has an accepted answers - jump to answer

Answers

  • larsonatorlarsonator Posts: 54Questions: 4Answers: 2

    im pretty sure you can add a change event listner on the set of check boxes, but set it to return the nearest 'tr' element. (that is if the checkbox is within one of the table cells

    $(".checkbox").on('change', 'tr', function(e){
        $(this).addClass('selected');  
    });
    

    i could be wrong? give it a go :)

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    @belldr - are you able to link to a page showing the problem you are having so we can fully understand the situation please. The impression I get at the moment is that the checkbox click is toggling the row selection, and you don't want that. Is that correct?

    If so, I would suggest adding an event handler to the checkboxes that will call event.stopPropagation() to stop the event from bubbling up to the tr element which has the click event handler.

    The other option is to use the TableTools option sRowSelector (assuming you are using TableTools for the row selection) to limit the row click selection to the first three columns.

    Allan

This discussion has been closed.