Get seletion value

Get seletion value

DotComDotCom Posts: 2Questions: 1Answers: 0

Im trying to get if a row is selected (most likely expecting true or false).

Im identifying my row using this table.row('#1')

Is there an extension available to check if this row is selected or not?

I searched in the documentation and online forums, including this one, but found nothing. Please point me to any related post or just mention the extention. Thanks

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    several ways but the most straight forward is probably
    assuming the row id is "1"...

    $(table.row("#1").node()).hasClass("selected");j

    or to get the selected row (assuming single select)

    table.row(".selected");

  • DotComDotCom Posts: 2Questions: 1Answers: 0

    Thank you!

    I was thinking of a more straigt forward way using the API instead of relying on the css class. But that works too. :smile:

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    table.rows('#1', { selected: true } ).any();
    

    is how to do it with the API. That basically does an AND between the row selector ('#1') and the row selector modifier ({selected: true}) - using any() to return a boolean value based on what was found.

    Allan

This discussion has been closed.