Filter Issue
Filter Issue
Hello,
I like the DataTables and its functionality..but I facing some problem.
Here I implementing the data tables.
Please look at once and check the searching and filtering option.Rest of the functionality is fine.
http://www.mypmo.co.uk/task_test_2.php?pid=18&oa=1#
When I put the where condition in sql query like this:
[code]
SELECT SQL_CALC_FOUND_ROWS tid, task_name, date_format(start_date,"%d-%m-%Y"), date_format(end_date,"%d-%m-%Y"), task_owner, task_progress FROM task where pid=18
[/code]
Some server side code is:
[code]
$sQuery = "SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
FROM $sTable
where uid=5
$sOrder
$sLimit ";
$rResult=$db->query($sQuery);
//$rResult = mysql_query( $sQuery ) or die(mysql_error());
/* Data set length after filtering */
$sQuery = "SELECT FOUND_ROWS()";
$rResultFilterTotal = $db->query( $sQuery);
$aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
$iFilteredTotal = $aResultFilterTotal[0];
/* Total data set length */
$sQuery = "
SELECT COUNT(".$sIndexColumn.")
FROM $sTable
";
$rResultTotal = $db->query( $sQuery) or die(mysql_error());
$aResultTotal = mysql_fetch_array($rResultTotal);
$iTotal = $aResultTotal[0];
/*
* Output
*/
$action='';
$sOutput = '{';
$sOutput .= '"sEcho": '.intval($_GET['sEcho']).', ';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
$sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', ';
$sOutput .= '"aaData": [ ';
$j=1;
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
for ( $i=0 ; $ifetchDetail('firstname','contacts','cid ='.$aRow[ $aColumns[$i] ])." ".$user->fetchDetail('lastname','contacts','cid ='.$aRow[ $aColumns[$i] ]);
$sOutput .= '"'.str_replace('"', '\"', $owner).'",';
}
else{
$sOutput .= '"'.str_replace('"', '\"', $aRow[ $aColumns[$i] ]).'",';
}
}
}
$j++;
/*
* Optional Configuration:
* If you need to add any extra columns (add/edit/delete etc) to the table, that aren't in the
* database - you can do it here
*/
//$sOutput.='"'.str_replace('"', '\"', 'delete' ).'",';
$action=$gen->actionDetail($_REQUEST['section'],$aRow['tid'],$_REQUEST['typeofAccess'],$_REQUEST['mode']);
$sOutput.='"'.str_replace('"', '\"', $action ).'",';
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';
echo $sOutput;
[/code]
and client side:
[code]
$(document).ready(function() {
oTable = $('#example').dataTable( {
"sScrollY": 200,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "includes/server_processing.php?section=task&mode=<?php echo $refer; ?>&typeofAccess=<?php echo $type_of_access; ?>",
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(6)', nRow).addClass( 'center' );
return nRow;
},
"fnDrawCallback": function ( oSettings ) {
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=0, iLen=oSettings.aiDisplay.length ; i
I like the DataTables and its functionality..but I facing some problem.
Here I implementing the data tables.
Please look at once and check the searching and filtering option.Rest of the functionality is fine.
http://www.mypmo.co.uk/task_test_2.php?pid=18&oa=1#
When I put the where condition in sql query like this:
[code]
SELECT SQL_CALC_FOUND_ROWS tid, task_name, date_format(start_date,"%d-%m-%Y"), date_format(end_date,"%d-%m-%Y"), task_owner, task_progress FROM task where pid=18
[/code]
Some server side code is:
[code]
$sQuery = "SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
FROM $sTable
where uid=5
$sOrder
$sLimit ";
$rResult=$db->query($sQuery);
//$rResult = mysql_query( $sQuery ) or die(mysql_error());
/* Data set length after filtering */
$sQuery = "SELECT FOUND_ROWS()";
$rResultFilterTotal = $db->query( $sQuery);
$aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
$iFilteredTotal = $aResultFilterTotal[0];
/* Total data set length */
$sQuery = "
SELECT COUNT(".$sIndexColumn.")
FROM $sTable
";
$rResultTotal = $db->query( $sQuery) or die(mysql_error());
$aResultTotal = mysql_fetch_array($rResultTotal);
$iTotal = $aResultTotal[0];
/*
* Output
*/
$action='';
$sOutput = '{';
$sOutput .= '"sEcho": '.intval($_GET['sEcho']).', ';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
$sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', ';
$sOutput .= '"aaData": [ ';
$j=1;
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
for ( $i=0 ; $ifetchDetail('firstname','contacts','cid ='.$aRow[ $aColumns[$i] ])." ".$user->fetchDetail('lastname','contacts','cid ='.$aRow[ $aColumns[$i] ]);
$sOutput .= '"'.str_replace('"', '\"', $owner).'",';
}
else{
$sOutput .= '"'.str_replace('"', '\"', $aRow[ $aColumns[$i] ]).'",';
}
}
}
$j++;
/*
* Optional Configuration:
* If you need to add any extra columns (add/edit/delete etc) to the table, that aren't in the
* database - you can do it here
*/
//$sOutput.='"'.str_replace('"', '\"', 'delete' ).'",';
$action=$gen->actionDetail($_REQUEST['section'],$aRow['tid'],$_REQUEST['typeofAccess'],$_REQUEST['mode']);
$sOutput.='"'.str_replace('"', '\"', $action ).'",';
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';
echo $sOutput;
[/code]
and client side:
[code]
$(document).ready(function() {
oTable = $('#example').dataTable( {
"sScrollY": 200,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "includes/server_processing.php?section=task&mode=<?php echo $refer; ?>&typeofAccess=<?php echo $type_of_access; ?>",
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(6)', nRow).addClass( 'center' );
return nRow;
},
"fnDrawCallback": function ( oSettings ) {
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=0, iLen=oSettings.aiDisplay.length ; i
This discussion has been closed.