How to not show the result of the search query until "enter key" is pressed?
-
How to not show the result of the search query until “enter key” is pressed?
I hope there is a trick for this one.
thanks Tobias
-
I’m using “TablePress Extension: DataTables Inverted Filter” also to hide the table first hand.
However, I found this and pasted it to my function.php and it is doing what I wanted it. BUT, when I search, I still see my old search result, every time I try for another search.
is there some way to hide the table or table results?, then show only after the “enter key” has been pressed?
thanks in advance.. Hoping you can help me out.
add_filter( ‘tablepress_datatables_command’, ‘tablepress_filter_on_enter’, 10, 5 );
function tablepress_filter_on_enter( $command, $html_id, $parameters, $table_id, $js_options ) {
$name = ‘DT_’ . str_replace( ‘-‘, ‘_’, $html_id );
$command = <<<JS
var {$name} = $(‘#{$html_id}’).dataTable({$parameters});
$(‘#{$html_id}_filter input’).unbind().bind(‘keyup’, function(e) {
if( 13 == e.keyCode )
{$name}.fnFilter( this.value );
});
JS;
return $command;
}Hi,
thanks for your post, and sorry for the trouble.
I don’t really understand what you mean. Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!
Regards,
TobiasHi Tobias,
here is the link:
https://www.greenisis.com/index.php/green-rates
i need it to work like this link: the search box on talk rates
https://www.menatelecom.com/en/residential/talk-rates.html
1. is there some way to hide the table or table results?, then show only after the “enter key” has been pressed?
2. and also, how can we restrict the search per word or per first letter only and not per letter in each word?
because we dont want to show all fields that cointains the letter a in that word, show only “a” if it is found on the first letter (this goes to all the letter in the alphabet too..for example, if you write “a” on the search box” all with “a” will be shown to you. we dont want that.
what im asking for, is some way it can be restricted for “a” having “a” as the first letter. so the display will be all fields that contains “a” as the first letter only
ex.
africa
argentina
antartica
a
a
athanks, hope you can shed some light. thanks in advance.
Hi,
thanks for the link!
1. This should be achieved after a small change to the “Inverted Filter” Extension’s code. In the file, change the lines
$( '.dataTables_filter' ).find( 'input' ).on( 'keyup', function() { $( '.dataTables_wrapper' ).find( '.tablepress' ).toggle( '' != $(this).val() ); } ).keyup();
to
$( '.dataTables_filter' ).find( 'input' ).on( 'keyup', function(e) { if( 13 == e.keyCode ) { $( '.dataTables_wrapper' ).find( '.tablepress' ).toggle( '' != $(this).val() ); } } ).keyup();
2. Sorry, I don’t have a solution for this. There’s no clean solution to achieve “full word” searching in the DataTables JS library, from what I know.
Regards,
TobiasHi Tobias,
Thanks for the reply..
I notice its hiding the result, that’s perfect, thanks. but the “columnheader” is still showing; in my link {country and rates column header} how can i hide it also and show only the search box?
??
Hi,
I’m not sure what you mean. Please try again after making that change.
Regards,
TobiasHi Again,
link: https://www.greenisis.com/index.php/green-rates
I only want to show the search box, no more under it at first.
how can I hide also these? basing on the link above.
Country Rates
No matching records foundThanks in advance
Hi,
when I visit that page right now, I only see the search field, but no table below it.
Only when I start typing, I see the “No matching records found” message.
And that’s what the code change that I mentioned above should remove as well.Regards,
Tobiasoh your right,
i guess its my browser fault, im using firefox, i tried in chrome and thats what i wanted.. do you know any work around for firefox browser?
BIG THANKS TOBIAS.
lastly, if you may, do you know any trick where atleast one must type minimum of 2 or 3 letters first before it can search? or can activate the enter key function?
Hi,
Firefox also works fine for me. Make sure that you are logged-out and maybe clear the cache.
The “Enter” key function is active. Just make that code change to see it working more nicely.
Regards,
TobiasHey Tobias,
That’s awesome.. You are right once again..
after i logged out.. its now fine.Thanks
again, lastly, if you may, do you know any trick where atleast one must type minimum of 2 or 3 letters first before it can search? or can activate the enter key function?
Really appreciate it. Regards too
Hi,
sorry, but if you are not reading what I’m writing, then I can’t help you.
Please make the code change that I mentioned: https://www.ads-software.com/support/topic/how-to-not-show-the-result-of-the-search-query-until-enter-key-is-pressed?replies=12#post-5322760Regards,
Tobias?? Sorry Tobias,
I saw it, i’m just hoping there is any magical work around.. =)
Thanks for the BIG HELP again..
Really fantastic plugin and support..
Hi,
no worries, it’s a very easy and small change.
Best wishes,
TobiasHi Tobias,
link: https://www.greenisis.com/index.php/rates
Sorry to bother again. Im having issue again with this things below my search box:
– 1st row of my header
2. No matching records foundhow can i hide this again? I only want the search box, and no more under.
Things I’ve checked and done
1. i already change the Inverted Filter” Extension’s to :
$( ‘.dataTables_filter’ ).find( ‘input’ ).on( ‘keyup’, function(e) {
if( 13 == e.keyCode ) {
$( ‘.dataTables_wrapper’ ).find( ‘.tablepress’ ).toggle( ” != $(this).val() );
}
} ).keyup();2. Clear my browser cache
3. log out of wp-admin
4.check it also with ie, chrome— but still it’s showing ??
Hope you’re well
- The topic ‘How to not show the result of the search query until "enter key" is pressed?’ is closed to new replies.