Page Refresh Problem
Page Refresh Problem

Hi Dears, am having a problem with search filter. I am using PhpCodeigniter. Search filter sends ajax request on every keypress which loads server I have huge records. Can somebody help me how to set search on Enter Key instead of keypress. Here is my code
function initialize_tbl_result_admin($url,$table_id = 'tbl_result', $params='')
{
$ci=& get_instance();
$aoData_push = '';
$custom_script = '';
$dcs = '';
if($params != ''){
$aoData_push = isset($params['aoData_push'])? $params['aoData_push']: '';
$custom_script = isset($params['custom_script'])? $params['custom_script']:'';
$dcs = isset($params['datatable_custom_settings'])? $params['datatable_custom_settings']:'';
}
$val1 = "<script type='text/javascript'>";
$val2 = "$(document).ready(function(){";
$val3 = "var ".$table_id." =$('#".$table_id."').DataTable({".$dcs."'responsive':true,'iDisplayLength':50,'aLengthMenu':[50, 100, 150, 200],'bProcessing':true,";
$val4 = "'bServerSide':true,'sAjaxSource':'".$url."',";
$val5 = "";//"'sPaginationType':'full_numbers','bAutoWidth':false,'aoColumnDefs': [{ 'bSortable': true, 'aTargets': [ '_all' ] },{ 'bSortable': false, 'aTargets': [ '_all' ] }],";
$val6 = "'fnServerData':function(sSource,aoData,fnCallback){aoData.push({ 'name':'request_type', 'value': 'ajax'});".$aoData_push;
$val7 = "
$.ajax({'dataType':'json','type':'POST','url':sSource,'data':aoData,'success':fnCallback});";
$val8 = "}});".$custom_script."});</script>";
$final_string = $val1.$val2.$val3.$val4.$val5.$val6.$val7.$val8;
return $final_string;
}
Replies
This example will show how to make this change:
http://live.datatables.net/jorexujo/6/edit
Alternatively you can use
searchDelay
to throttle the searches.With server side processing the server script should limit the number of records returned. Is that not happening?
Kevin
thanks sir..Nice support system. Again Special thanks to all Datatables team members