refresh JSON datasource (form search result) without using ajax
refresh JSON datasource (form search result) without using ajax
Hi, I have a search form that execute using ajax and return a JSON object (list) but can't figure out how to refresh the table with the new result, the table initially is empty,
I saw the custom var example http://datatables.net/examples/server_side/custom_vars.html but I don't want the dataTable to do the ajax request (unless there is a way to make my submit-search button trigger refresh on the table and make it pick my form values automatically ?)
thanks
I saw the custom var example http://datatables.net/examples/server_side/custom_vars.html but I don't want the dataTable to do the ajax request (unless there is a way to make my submit-search button trigger refresh on the table and make it pick my form values automatically ?)
thanks
This discussion has been closed.
Replies
Example js
[code]
$('#demo').html( '' );
var t = $('#demoTable').dataTable( {
"sPaginationType": "full_numbers",
"sAjaxSource": "/yourAjaxFunction.php",
"bDeferRender": true,
"iDisplayLength": 10,
"aoColumns": [
{ "sTitle": "Column One Name" },
{ "sTitle": "Column Two Name" },
{ "sTitle": "Column Three Name" }
]
} );
[/code]
Example PHP
[code]
$iTotal = count($Data);
$output = array(
"sEcho" => "1",
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => "10",
"aaData" => array()
);
foreach ( $Data as $temp )
{
$row = array();
$row[] = $temp['column_one'];
$row[] = $temp['column_two'];
$row[] = $temp['column_three'];
$output['aaData'][] = $row;
}
echo json_encode($output);
[/code]