Server Side processing,filtering and ajax call
Server Side processing,filtering and ajax call
Hi,
I'm succesfully using datatables, with server side processing and filtering but I need an optimization:
[code]
jQuery(document).ready(function() {
oTable=jQuery('#my_table).dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajax_ads/process_qry.php"
} );
[/code]
Now an Ajax call to process_qry.php is made on every keystroke of the user in the filter field, Is it possible to make the call only when the user hit the Enter key ??? Thank you in advance !!
I'm succesfully using datatables, with server side processing and filtering but I need an optimization:
[code]
jQuery(document).ready(function() {
oTable=jQuery('#my_table).dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajax_ads/process_qry.php"
} );
[/code]
Now an Ajax call to process_qry.php is made on every keystroke of the user in the filter field, Is it possible to make the call only when the user hit the Enter key ??? Thank you in advance !!
This discussion has been closed.
Replies
The method will then look like:
[code]
function _fnFeatureHtmlFilter ( oSettings )
{
var nFilter = document.createElement( 'div' );
if ( oSettings.sTableId !== '' )
{
nFilter.setAttribute( 'id', oSettings.sTableId+'_filter' );
}
nFilter.className = oSettings.oClasses.sFilter;
var sSpace = oSettings.oLanguage.sSearch==="" ? "" : " ";
nFilter.innerHTML = oSettings.oLanguage.sSearch+sSpace+'';
var jqFilter = $("input", nFilter);
jqFilter.val( oSettings.oPreviousSearch.sSearch.replace('"','"') );
jqFilter.keyup(function(e) {
if (e.keyCode == 13)
_fnFilterComplete( oSettings, {
"sSearch": this.value,
"bEscapeRegex": oSettings.oPreviousSearch.bEscapeRegex
} );
} );
jqFilter.keypress( function(e) {
/* Prevent default */
if ( e.keyCode == 13 )
{
return false;
}
} );
return nFilter;
}
[/code]
I only have version 1.5.4 to look at right now, so the method may have changed, but I tried it and it seems to work. I'm sure Allan will have a better solution...
Now I've to find how to apply the same solution to the column based filter.
Thank you again ...
Allan