how can I tigger a search in the searchPanes extension?

how can I tigger a search in the searchPanes extension?

alhuber1502alhuber1502 Posts: 9Questions: 3Answers: 0

Is there a way to programmatically launch a search in a searchPane (that would result in the row in the searchPane to be selected as if it had been clicked on), something analogous to

table.columns(9).search( 'term' ).draw();

but within the searchPanes? Many thanks!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    See this thread. Even though its a year old I believe the answers still apply. The example in the thread shows how it can be done. But programmically finding the correct search pane and find the correct row to select would take a lot of work.

    Kevin

  • alhuber1502alhuber1502 Posts: 9Questions: 3Answers: 0

    Thanks, @kthormann !
    This doesn't seem to work with long searchPane tables, as they're not automatically loaded into the DOM on init. I don't suppose there's a way to enforce this?

    Thanks!

  • alhuber1502alhuber1502 Posts: 9Questions: 3Answers: 0

    Apologies for misspelling your name, @kthorngren !

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    Answer ✓

    Instead of using this to find the row:

    let row = $('#DataTables_Table_0').find('tr:nth-child(1)');
    

    You can use row() with a row-selector as a function to find the row. For example:
    https://live.datatables.net/pafizoxu/10/edit

    Kevin

  • alhuber1502alhuber1502 Posts: 9Questions: 3Answers: 0

    Ah, that works perfectly. Thank you so much, @kthorngren !

Sign In or Register to comment.