Hello. I finally was able to make the table work in such way that a search is done only when the Enter key is pressed (not every keypress as currently). I spent various days to figure it out and finally achieved it (Thank God primarily!). I read various threads in forums; I tried fnSetFilteringDelay plugin for Datatables (datatables.net) too - to delay call to search while typing - without being able to make it work (maybe some people have done it successfully); anyway, this thread was very very useful for me:
stackoverflow.com/questions/14619498/datatables-global-search-on-keypress-of-enter-key-instead-of-any-key-keypress/.
Basically, what I did was to modify the file told before by Admin: <joomla_directory>\modules\mod_aridatatables\includes\kernel\DataTables\Models\class.DataTablesWidgetDatatableModel.php in the following way:
Code: |
function initClientInstance($id, $params, $hiddenColumns, $mParams, $columnsSettings)
{
$cfg = $mParams['_default'];
$useJQueryUI = (bool)$params['bJQueryUI'];
if ($useJQueryUI)
AriDataTablesHelper::includeJQueryUITheme($cfg['jQueryUITheme']);
$loadMethod = AriUtils::getParam($params, 'loadMethod', 'ready');
$jsOptions = $this->getJsOptions($id, $params, $hiddenColumns, $mParams, $columnsSettings);
$fixedColCode = $this->getFixedColCode(AriUtils::getParam($params, 'fixedcols', array()));
$dtCode = sprintf('if (typeof(AriDataTables) != "undefined") AriDataTables.hideLoadingPane("#%1$s_wrapper");var options = %2$s;options["fnDrawCallback"] = function(oSettings) { adt_DataTable_DrawCallback(oSettings) }; var dt = $("#%1$s").addClass("display dataTable").dataTable(options);%3$s',
$id,
!empty($jsOptions) ? AriJSONHelper::encode($jsOptions) : '',
$fixedColCode
//!empty($jsOptions['bJQueryUI']) ? sprintf('/*$("#%1$s_wrapper").find(".dataTables_wrapper").addClass("ui-widget-content")*/', $id) : ''
);
[b]$custom_code = sprintf('$("#%1$s_filter input").unbind(); $("#%1$s_filter input").bind("keyup", function(e) { if(e.keyCode == 13) { dt.fnFilter(this.value) } });',
$id
);[/b]
$document =& JFactory::getDocument();
if ($loadMethod == 'load')
$document->addScriptDeclaration(';(window["ADTQuery"] || jQuery)(window).load(function() { var $ = window["ADTQuery"] || jQuery;' . $dtCode . [b]$custom_code . [/b]'});');
else
$document->addScriptDeclaration(';(window["ADTQuery"] || jQuery)(document).ready(function($) { ' . $dtCode . [b]$custom_code . [/b]'});');
}
|
Notice the bold expressions - between
tags (which must not be in the code) - which were those I added.
Thank you very much. It would be great Admin adds this option to search by Enter key instead of every keypress in the backend for next version.
I am using server-side processing with a large table (around 49 000 rows).