Initialize with default search

Initialize with default search

bikedorkseattlebikedorkseattle Posts: 20Questions: 1Answers: 0
edited June 2012 in General
Is there a way to initialize datatables with a default search in the input box? I'd like to add a datatable to product pages with the product selected but allow people to refine their search.

I've been able to set the input box value with jQuery, but I haven't figured out how to submit it since it's requires a keypress.

$('#example_filter label input[type=text]').val('Default Product')

Edit: I forgot to add if it's not obvious that I'm doing server side.

TIA

Replies

  • bikedorkseattlebikedorkseattle Posts: 20Questions: 1Answers: 0
    This did the trick.

    $('#example_filter label input[type=text]').val('Default Product').trigger($.Event("keyup", { keyCode: 13 }));

    However it's making two calls to the server.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    > Is there a way to initialize datatables with a default search in the input box?

    Yes - the oSearch parameter allows this.

    Allan
  • bikedorkseattlebikedorkseattle Posts: 20Questions: 1Answers: 0
    Awesome, thanks Allan!
This discussion has been closed.