sbokan1
Forum Replies Created
-
Forum: Plugins
In reply to: [TablePress - Tables in WordPress made easy] Cant search when table is hiddenI just realized that I need to enter the page slug, BUT I have more than one table on the page and want to leave the others visible. Is that possible?
Forum: Plugins
In reply to: [TablePress - Tables in WordPress made easy] Cant search when table is hiddenI have the TablePress Extension: DataTables Inverted Filter but Im not sure how to apply it to the table I want.
The code below worked, it just wasn’t closed when you posted it. Thanks for you help!! ??
<?php 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; } ?>
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
What if I set the search box to only show results when the enter button is pressed.
I found this code from one of your previous posts:
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;
}Im just not sure where in the functions.php it should go?
I think it is more clear to say that the search box only recognizes exact terms on the columns, and doesn’t show any results until the all numbers are satisfied, ie only shows results when 02-2016 is typed. But if someone types in just 6 in the search nothing will show up.
One last question,
Can the filter be limited to recognize only whole values of the column.
Customer ID:
02-2016
03-2016
04-2016When I enter just the number 6, all of the entries show up
I put the following and it worked:
“aoColumnDefs”: [ { “bSearchable”: false, “aTargets”: [ 1,2,3,4 ] } ]
You are amazing! How do I donate to your site?
I think I figured it out, I didnt get the numbering right ??
You have the right idea, I would enter the following so that only column on e is searchable:
“aoColumnDefs”: [ { “bSearchable”: false, “aTargets”: [ 2,3,4,5,6 ] } ]
The problem is that the search box dissapears and all the content of the table appear.
See the site below: