Possibility to select a specific search pane filter from outside

Possibility to select a specific search pane filter from outside

Pete44Pete44 Posts: 22Questions: 7Answers: 0
edited July 2020 in Free community support

Is there a possibility to select a specific search pane filter from outside? For example with a click on a button or anchor link?

For example: https://datatables.net/extensions/searchpanes/examples/initialisation/simple.html
If I click on "Tokyo" (first row, third column) the Tokyo filter in the Office search pane will be selected and executed.

I couldn't find any hint in the API docs. Maybe I searched on the wrong places.

This question has accepted answers - jump to:

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi @Pete44

    Take a look at this example. I'm using jQuery here to access the panes DataTables and then select the desired row from there. I'm afraid that there currently this is the best way to do this.

    Thanks,
    Sandy

  • Pete44Pete44 Posts: 22Questions: 7Answers: 0
    edited July 2020

    Hey @sandy

    sorry for the late reply (looks like email notification doesn't work properly). Thanks a lot for your suggestion. I'm not sure if this will help. I will test it tomorrow and your example will help to build the test case. I think it will be difficult to build links on table rows for enable/disable specific panes. It's not really important, but in my case it would increase the usability of the datatable a lot if a user could easily click on a specific link in a table cell to enable/disable a filter.

    But if I see your example correct, it could work as I need it. So many thanks again for your fast help. I will reply later if I tested it.

  • Pete44Pete44 Posts: 22Questions: 7Answers: 0

    I got it working for my use case. Your example was very helpful and I could use it to implement it on my specific datatable. :)

    Thanks again @sandy!

  • Pete44Pete44 Posts: 22Questions: 7Answers: 0

    Sorry, I have to bump this question again. I noticed, that there are some issues with cascades enabled.

    I made an example: http://live.datatables.net/nenoxoji/2/edit
    Steps to reproduce:
    1. In searchpane Position choose "Technical Author"
    2. Click the London-Button

    As you can see, it will choose the wrong entry in the Office searchpane (San Francisco). I took a deeper look and there is something strange with the choosen index. I guess the searchpane array differs because of the previous selection and now the used index is wrong.
    Unfortunately I've absolutely no idea what I could do to prevent that issue.

    Would be very cool, if there is a possibility to get this working with enabled cascades too.

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @Pete44 ,

    Cascade completely redraws the tables after different selections, often this means that it is easy to get things muddled up. Here the index property within the row data is the index when all of the rows are present, as soon as the cascade operation occurs, the table's row indexes are changed, hence why your example is selecting the wrong row.

    Take a look at this example, it is similar to the original. Here though we are iterating through the rows in the table using the tables indexing rather that SearchPanes.

    Hope this helps,
    Sandy

  • Pete44Pete44 Posts: 22Questions: 7Answers: 0
    edited September 2020

    Hi @sandy,

    thanks for your reply. Unfortunately your example doesn't work for me. If I click on the London button nothing happens.

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi @Pete44 ,

    Sorry, slight bug in the previous one where it only worked for London after filtering. Take a look at this example instead.

    Thanks,
    Sandy

  • Pete44Pete44 Posts: 22Questions: 7Answers: 0
    edited September 2020

    Hi @sandy,

    thanks a lot. It's working now. :)

This discussion has been closed.