Column filter on server side
Column filter on server side
When I want to implement option columnFilter on Server side, I don't receive response, only show "Processing..."
Help? where is error? or how to call datatable to show results picked from query in db.php file?
processing" : true,
"serverSide" : true,
"sAjaxSource": "db.php",
"sPaginationType" : "full_numbers",
"fnServerData" : function(sUrl, aoData, fnCallback) {
aoData.push({"name":"id","value":""});
$.ajax({
"contentType": "application/json; charset=utf-8",
"url" : sUrl,
"data" : aoData,
"type":"GET",
"success" : function(response){
t.fnReloadAjax();
},
"dataType" : "json"
});
}
}).columnFilter({
aoColumns : [null,{ type:"text"},{ type:"text"},{
type : "select",
values : ['tip1', tip2', 'tip3', 'tip4']
}, {
type : "text"
}, {
type : "text"
}, {
type : "text"
},
null]
});
Thank you!
```php
<?php
include("dbconfig.php");
$table = $db_table;
$primaryKey = 'id';
$myJoin = " INNER JOIN table2 ON table1.idExternal = table2.id ";
$columns = array(
array(
'db' => 'id',
'dt' => 'DT_RowId',
'formatter' => function( $d, $row ) {
return $d;
}
),
array( 'db' => 'column0', 'dt' => 0 ),
array( 'db' => 'column1', 'dt' => 1 ),
array( 'db' => 'column2', 'dt' => 2 ),
array( 'db' => 'column3', 'dt' => 3 ),
array( 'db' => 'column4', 'dt' => 4 ),
array( 'db' => 'column5', 'dt' => 5,'formatter' => function( $d, $row ) {
return date( 'jS M y', strtotime($d));
}),
array( 'db' => 'column6', 'dt' => 6 ),
array( 'db' => 'column7', 'dt' => 7 )
);
// SQL server connection information
$sql_details = array(
'user' => $db_user,
'pass' => $db_pass,
'db' => $db_db,
'host' => $db_server
);
require( 'DataTables-1.10.4/examples/server_side/scripts/ssp.class.php' );
echo json_encode(SSP::simple( $_GET, $sql_details, $table,$myJoin, $primaryKey, $columns ));
Answers
There is an error in the server-side script in that case. Look at the Ajax return in your browser's developer tools to find out what the error is.
Allan
db.php file, that return ajax data, show error:
In debug information i have this:
When I remove "sAjaxSource": "db.php" and columnFilter({...}) from jQuery code, data are shown, but don't have column filter on server side what I need...
please answer this question too about datatable server side filtering. thanks
http://datatables.net/forums/discussion/comment/71584#Comment_71584
@umair_malik - Please follow the forum rules and don't post duplicates. You are less likely to get a reply if you break the rules.
Allan