Data not show in dataTable but in XHR sEcho result show
Data not show in dataTable but in XHR sEcho result show
Hi all,
i get some problem during add one column to my dataTable.
I don't understand why its happen because i get no error message from my console. And Also in XHR, I can see the result of sEcho.
This problem happen during add Range column in dataTable.
[code]
oTable = $("#Accept").dataTable({
"bRetrieve" : true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": 'check.php',
"fnServerData": function (sSource,aoData,fnCallback){
aoData.push({"name":"date","value":$("#date").val()});
aoData.push({"name":"line","value":$("#line").val()});
aoData.push({"name":"model","value":$("#model").val()});
aoData.push({"name":"lot","value":$("#lot").val()});
aoData.push({"name":"range","value":$("#range").val()});
//$.ajax..........
"aaSorting" : [[1,"desc"]],
"aoColumns" : [
/*Date*/null,
/*Line*/ null,
/*Model*/ null,
/*Lotno*/null,
/*Range*/null
]
[/code]
And this the server side script:
[code]
if (postVar('sSearch') !="" )
{
/* $sWhere = ..........*/
}
$sGroupBy = " GROUP BY A.Line, A.Model, A.Lot_no, A.Range_sampling ";
$sQuery = "SELECT DATE(A.Inspection_datetime) AS Date, A.Line,TRIM(A.Model) AS Model, A.Lot_no,
A.Range_sampling
FROM inspection_report A
LEFT JOIN Employee B
ON A.NIK=B.NIK
WHERE CHAR_LENGTH(Range_sampling) = 17 OR `Issue`='' OR `Check`='' OR `Approve`=''" .$sWhere.$sGroupBy.$sOrder.$sLimit;
$rResult = mysql_query( $sQuery) or _doError(_ERROR30 . ' (' . htmlspecialchars($sql) . '): ' . mysql_error() );
/*put same script after query above*/
$sOutput = '{';
$sOutput .= '"sEcho": '.intval($_POST['sEcho']).',';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
// $sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', \';
$sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
$sOutput .= '"aaData": [ ';
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
$sOutput .= '"'.addslashes($aRow['Date']).'",';
$sOutput .= '"'.addslashes($aRow['Line']).'",';
$sOutput .= '"'.addslashes($aRow['Model']).'",';
$sOutput .= '"'.addslashes($aRow['Lot_no']).'",';
$sOutput .= '"'.addslashes($aRow['Range_sampling']).'"';
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';
echo $sOutput;
function fnColumnToField( $i )
{
if ( $i == 0 )
return "Date";
else if ( $i == 1 )
return "Line";
else if ( $i == 2 )
return "Model";
else if ( $i == 3 )
return "Lot_no";
else if ( $i == 4 )
return "Range_sampling";
}
[/code]
i get some problem during add one column to my dataTable.
I don't understand why its happen because i get no error message from my console. And Also in XHR, I can see the result of sEcho.
This problem happen during add Range column in dataTable.
[code]
oTable = $("#Accept").dataTable({
"bRetrieve" : true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": 'check.php',
"fnServerData": function (sSource,aoData,fnCallback){
aoData.push({"name":"date","value":$("#date").val()});
aoData.push({"name":"line","value":$("#line").val()});
aoData.push({"name":"model","value":$("#model").val()});
aoData.push({"name":"lot","value":$("#lot").val()});
aoData.push({"name":"range","value":$("#range").val()});
//$.ajax..........
"aaSorting" : [[1,"desc"]],
"aoColumns" : [
/*Date*/null,
/*Line*/ null,
/*Model*/ null,
/*Lotno*/null,
/*Range*/null
]
[/code]
And this the server side script:
[code]
if (postVar('sSearch') !="" )
{
/* $sWhere = ..........*/
}
$sGroupBy = " GROUP BY A.Line, A.Model, A.Lot_no, A.Range_sampling ";
$sQuery = "SELECT DATE(A.Inspection_datetime) AS Date, A.Line,TRIM(A.Model) AS Model, A.Lot_no,
A.Range_sampling
FROM inspection_report A
LEFT JOIN Employee B
ON A.NIK=B.NIK
WHERE CHAR_LENGTH(Range_sampling) = 17 OR `Issue`='' OR `Check`='' OR `Approve`=''" .$sWhere.$sGroupBy.$sOrder.$sLimit;
$rResult = mysql_query( $sQuery) or _doError(_ERROR30 . ' (' . htmlspecialchars($sql) . '): ' . mysql_error() );
/*put same script after query above*/
$sOutput = '{';
$sOutput .= '"sEcho": '.intval($_POST['sEcho']).',';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
// $sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', \';
$sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
$sOutput .= '"aaData": [ ';
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
$sOutput .= '"'.addslashes($aRow['Date']).'",';
$sOutput .= '"'.addslashes($aRow['Line']).'",';
$sOutput .= '"'.addslashes($aRow['Model']).'",';
$sOutput .= '"'.addslashes($aRow['Lot_no']).'",';
$sOutput .= '"'.addslashes($aRow['Range_sampling']).'"';
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';
echo $sOutput;
function fnColumnToField( $i )
{
if ( $i == 0 )
return "Date";
else if ( $i == 1 )
return "Line";
else if ( $i == 2 )
return "Model";
else if ( $i == 3 )
return "Lot_no";
else if ( $i == 4 )
return "Range_sampling";
}
[/code]
This discussion has been closed.