How do I get the top visible row Id after a search filter?

How do I get the top visible row Id after a search filter?

alphadadalphadad Posts: 12Questions: 6Answers: 0

I'm trying to work with the row id of the top visible row after filtering with the Search input. How do I access it's value?

This question has an accepted answers - jump to answer

Answers

  • alphadadalphadad Posts: 12Questions: 6Answers: 0
    table.rows( {search:'applied'} ).nodes()[0].id
    

    ... seems to work ... anybody have anything more elegant?

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Answer ✓
    table.row( {search:'applied'} ).node().id
    

    should also work. If the selector matches multiple rows when using the singular method (row() rather than rows()) it will just truncate the result set to the first row.

    The down side is that when you or someone comes back to that code in a year you might wonder how it works if you don't remember that fact!

    Allan

  • alphadadalphadad Posts: 12Questions: 6Answers: 0

    Thanks Allan :)

This discussion has been closed.