Support » Plugin: TablePress » Programmatic Search

  • Resolved jcramer10

    (@jcramer10)


    This seems like a simple task but I’m unable to find examples or prior topics.

    I want to search my table programmatically – i.e. javascript that will populate the search input field and trigger a search. I can populate the search input field via:
    $(“#tablepress-1_filter :input”).val(‘example’)

    However, I can’t trigger a search. Any advice? The idea is to have several links above the table that auto-filter it (it’s supposed to be a searchable phone list with common searches).

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    To trigger the search, just call the change() event:

    $("#tablepress-1_filter :input").val('example').change();
    

    You might also want to take a look at the TablePress Button Filter Extension from https://tablepress.org/extensions/datatables-button-filter/

    Regards,
    Tobias

    Thanks for getting back to me. That doesn’t seem to work either – tried Chrome, Firefox, and IE.

    I just have a hyperlink above the tablepress shortcode that looks like this:
    CT

    Typing in the search input filters the table just fine. I can click in the search box after clicking the link, press a key, and the filtering happens. It almost seems like the browsers are blocking it?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ah, maybe, you’ll have to use .keydown() instead of .change() then. If that also does not help, I recommend to check how the JavaScript code of the mentioned extension does it.

    Regards,
    Tobias

    keydown() also seems to be blocked but the button filter extension works great – that’s way better. Thanks!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    not sure why your code is not working then, sorry. But good to hear that the Extension is working 🙂

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

    Done. Also, the button filter extension isn’t shown on the extensions page.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks! Yes, it’s not shown on that page, I first need to update more documentation.

    Regards,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Programmatic Search’ is closed to new replies.