How to activate a search pane filter programmatically

How to activate a search pane filter programmatically

chimouchimou Posts: 7Questions: 0Answers: 0

Hello everybody,

I am trying to access and enable a specific filter of a search pane dynamically.
My search panes are located inside a button.
I did not find any solution on this topic.

Thank you for your support

Replies

  • allanallan Posts: 58,914Questions: 1Answers: 9,485 Site admin

    Rather than dynamically, do you mean programmatically? I.e. via an API call? If so, there isn't yet an option to do that with SearchPanes I'm afraid.

    Allan

  • chimouchimou Posts: 7Questions: 0Answers: 0

    Hello Allan,

    Thank you for replying.
    Yes I mean programmatically, actually I am trying to do like that but it does not work :

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

    With 'DataTables_Table_0' is the identifier auto generated and associated to search pane #1.

    Note: All my search panes are initially masked under a button

  • chimouchimou Posts: 7Questions: 0Answers: 0

    Actually, it seems search panes tables are only created once they are visible, i.e. when they are masked behind the button, they even do not exist in DOM.

    Do you have any workaround ?

  • colincolin Posts: 14,803Questions: 1Answers: 2,524

    Your code snippet works here - when clicking the button at the top of the page. Is that the flow you had in mind, or are you trying something else?

    Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Colin

  • chimouchimou Posts: 7Questions: 0Answers: 0

    Hello Colin,

    Yes it works when the search panes are visible i.e. created.
    But as I mentioned before, all my search panes are initially not visible.
    Consequently I can not get a reference of a specific search pane.

    I just updated your test case to show my workflow (the only difference is I load an external dataset via an ajax call) :

    https://live.datatables.net/pafizoxu/2/edit

    Please let me know if you have any idea, thank you.

  • allanallan Posts: 58,914Questions: 1Answers: 9,485 Site admin

    Unfortunately no - there isn't an API method to get the instances for the SearchPane. That's one of the bugs on my todo list!

    Allan

  • chimouchimou Posts: 7Questions: 0Answers: 0

    OK Allan no problem, thank you both for your support.
    How can I be noticed when a fix on this topic will be made please ?

    Best regards

  • allanallan Posts: 58,914Questions: 1Answers: 9,485 Site admin

    I've added a note into our internal bug (DD-2297) to post back to this thread when I've fixed it.

    Allan

  • chimouchimou Posts: 7Questions: 0Answers: 0

    Excellent Allan, have a good day !

Sign In or Register to comment.