How to set default value for search filter #477
-
I want to set the default value for search filter when backpack list page is loaded, so that the result is filtered by the search value i sepcified. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As far as I know this is not possible inside the search field itself. A possible workaround (if you are OK to have a filter instead of the search bar), is to create a text filter: https://backpackforlaravel.com/docs/5.x/crud-filters#text-1. Then you can change the menu link of your list from You can find some other possible solutions that require modifying the data table itself here: https://stackoverflow.com/questions/45202366/how-to-allow-get-request-to-search-laravel-backpack |
Beta Was this translation helpful? Give feedback.
-
Thank Dimitar for the reply, gave me some hint to make it work. and adding the js code in the view <script> jQuery(document).ready(function($) { $('input[type=search]').val("{{Request::input('qsearch')}}"); $('input[type=search]').trigger('keyup'); }); </script> |
Beta Was this translation helpful? Give feedback.
As far as I know this is not possible inside the search field itself.
A possible workaround (if you are OK to have a filter instead of the search bar), is to create a text filter: https://backpackforlaravel.com/docs/5.x/crud-filters#text-1. Then you can change the menu link of your list from
https://website.test/admin/product
to something likehttps://website.test/admin/product?myfilter=test
. This way the admin will see the preset filter when they visit the list, but later on they would have to remove/update the filter value and not the search field if they want to change the results.You can find some other possible solutions that require modifying the data table itself here: https://st…