Datatables and Wordpress Server Side Processing Integration problem solved.
Datatables and Wordpress Server Side Processing Integration problem solved.
nirajkvinit
Posts: 1Questions: 0Answers: 0
Hi,
Like other wordpress developers, I had also faced the problem of integrating datatable(server side processing) with wordpress. I tried every tips, tricks and multiple ways to solve the problem, but couldn't do it. My ajaxified functions of the wordpress simple dint work. I din't have much time and had to finish a small project on time. So, I decided to skip it and go through the simple way. The way - the plugin developer had suggested and implemented.
Read the complete story here http://nirajkvinit.blogspot.in/2013/01/datatables-and-wordpress-integration.html
Codes are:
My js code for datatable is:
[code]oTable = jQuery('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": ajaxurl+'?action=fn_my_ajaxified_dataloader_ajax',
"sServerMethod": "POST",
"bDeferRender": true,
"fnServerData": fnDataTablesPipeline,
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "200px"
});[/code]
My Wordpress PHP Code:
Define Ajax Actions
[code]add_action('wp_ajax_fn_my_ajaxified_dataloader_ajax', 'fn_my_ajaxified_dataloader_ajax');
add_action('wp_ajax_nopriv_fn_my_ajaxified_dataloader_ajax', 'fn_my_ajaxified_dataloader_ajax');[/code]
Now the wordpress Function
[code]function fn_my_ajaxified_dataloader_ajax()
{
global $wpdb;
$aColumns = array( 'engine', 'browser', 'platform', 'version', 'grade' );
$sIndexColumn = "id";
$sTable = "ajax";
$sLimit = "";
if ( isset( $_REQUEST['iDisplayStart'] ) && $_REQUEST['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_REQUEST['iDisplayStart'] ).", ".
intval( $_REQUEST['iDisplayLength'] );
}
$sOrder = "";
if ( isset( $_REQUEST['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $iget_results($sQuery, ARRAY_A);
$iTotal = $aResultTotal[0];
$output = array(
"sEcho" => intval($_REQUEST['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
foreach($rResult as $aRow)
{
$row = array();
for ( $i=0 ; $i
Like other wordpress developers, I had also faced the problem of integrating datatable(server side processing) with wordpress. I tried every tips, tricks and multiple ways to solve the problem, but couldn't do it. My ajaxified functions of the wordpress simple dint work. I din't have much time and had to finish a small project on time. So, I decided to skip it and go through the simple way. The way - the plugin developer had suggested and implemented.
Read the complete story here http://nirajkvinit.blogspot.in/2013/01/datatables-and-wordpress-integration.html
Codes are:
My js code for datatable is:
[code]oTable = jQuery('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": ajaxurl+'?action=fn_my_ajaxified_dataloader_ajax',
"sServerMethod": "POST",
"bDeferRender": true,
"fnServerData": fnDataTablesPipeline,
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "200px"
});[/code]
My Wordpress PHP Code:
Define Ajax Actions
[code]add_action('wp_ajax_fn_my_ajaxified_dataloader_ajax', 'fn_my_ajaxified_dataloader_ajax');
add_action('wp_ajax_nopriv_fn_my_ajaxified_dataloader_ajax', 'fn_my_ajaxified_dataloader_ajax');[/code]
Now the wordpress Function
[code]function fn_my_ajaxified_dataloader_ajax()
{
global $wpdb;
$aColumns = array( 'engine', 'browser', 'platform', 'version', 'grade' );
$sIndexColumn = "id";
$sTable = "ajax";
$sLimit = "";
if ( isset( $_REQUEST['iDisplayStart'] ) && $_REQUEST['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_REQUEST['iDisplayStart'] ).", ".
intval( $_REQUEST['iDisplayLength'] );
}
$sOrder = "";
if ( isset( $_REQUEST['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $iget_results($sQuery, ARRAY_A);
$iTotal = $aResultTotal[0];
$output = array(
"sEcho" => intval($_REQUEST['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
foreach($rResult as $aRow)
{
$row = array();
for ( $i=0 ; $i
This discussion has been closed.