How to activate a search pane filter programmatically

How to activate a search pane filter programmatically

chimouchimou Posts: 9Questions: 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: 63,689Questions: 1Answers: 10,500 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: 9Questions: 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: 9Questions: 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: 15,240Questions: 1Answers: 2,599

    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: 9Questions: 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: 63,689Questions: 1Answers: 10,500 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: 9Questions: 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: 63,689Questions: 1Answers: 10,500 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: 9Questions: 0Answers: 0

    Excellent Allan, have a good day !

  • chimouchimou Posts: 9Questions: 0Answers: 0

    Hello Allan,

    I hope you are doing well.
    I come back on this topic to know if there is any update ?

    Thank you !
    Best regards,

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    Hi,

    I'm sorry to say I haven't done any work on this issue yet. I've been prioritising work on DataTables 2 over the SearchPanes rewrite.

    Allan

  • chimouchimou Posts: 9Questions: 0Answers: 0

    Hi Allan,

    Thank you for your feedback. Will Datatables2 include an upgrade on SearchPanes ?

    Have a great day !

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    Kind of. DataTables will have new APIs that SearchPanes will be able to use, but it will not alter the features of SearchPanes. A rewrite of SearchPanes will likely follow the DataTables 2 release, but I don't have a specific date for it.

    Allan

Sign In or Register to comment.