Help please: row details with server side processing
Help please: row details with server side processing
david_lyon
Posts: 8Questions: 0Answers: 0
Hi Everyone
I would be grateful if someone could provide the piece of code that will get the row details with server side processing working.
I spent days looking at the examples and this link http://datatables.net/release-datatables/examples/server_side/row_details.html.
I provide the html code and the server side processing script that I am using.
Can someone please show me how to get row details with server side processing working with the code below?
Many Thanks in advance.
Here is my html code:
[code]
var oTable;
function fnFormatDetails ( nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Rendering engine:'+aData[2]+' '+aData[5]+'';
sOut += 'Link to source:Could provide a link here';
sOut += 'Extra info:And any further details here (images etc)';
sOut += '';
return sOut;
}
$(document).ready(function(){
var oTable = $('#example').dataTable(
{
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "http://$url/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls.swf",
"aButtons": [
{
"sExtends": "copy",
"sButtonText": "Copy to clipboard"
},
{
"sExtends": "csv",
"sButtonText": "Save to CSV"
},
{
"sExtends": "xls",
"sButtonText": "Save for Excel"
}
]
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./server_processingC1.php",
"iDisplayLength": 5,
"sPaginationType": "full_numbers",
"oLanguage": { "sSearch": "Search all columns:",
},
"aoColumnDefs": [
{
"aTargets": [ 7 ], // Column to target
"mRender": function ( data, type, full ) {
// 'full' is the row's data object, and 'data' is this column's data
// e.g. 'full[0]' is the comic id, and 'data' is the comic title
return '' + data + '';
}
}
]
} );
$('#example tbody td img').live( 'click', function () {
var nTr = $(this).parents('tr')[0];
if ( oTable.fnIsOpen(nTr) )
{
/* This row is already open - close it */
this.src = "http://$url/DataTables-1.9.4/examples/examples_support/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "http://$url/DataTables-1.9.4/examples/examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
}
} );
} );
;
$name
Preamble
One line of text here
$name
A
B
C
D
E
F
G
H
I
Loading data from server
H
I
[/code]
I would be grateful if someone could provide the piece of code that will get the row details with server side processing working.
I spent days looking at the examples and this link http://datatables.net/release-datatables/examples/server_side/row_details.html.
I provide the html code and the server side processing script that I am using.
Can someone please show me how to get row details with server side processing working with the code below?
Many Thanks in advance.
Here is my html code:
[code]
var oTable;
function fnFormatDetails ( nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Rendering engine:'+aData[2]+' '+aData[5]+'';
sOut += 'Link to source:Could provide a link here';
sOut += 'Extra info:And any further details here (images etc)';
sOut += '';
return sOut;
}
$(document).ready(function(){
var oTable = $('#example').dataTable(
{
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "http://$url/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls.swf",
"aButtons": [
{
"sExtends": "copy",
"sButtonText": "Copy to clipboard"
},
{
"sExtends": "csv",
"sButtonText": "Save to CSV"
},
{
"sExtends": "xls",
"sButtonText": "Save for Excel"
}
]
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./server_processingC1.php",
"iDisplayLength": 5,
"sPaginationType": "full_numbers",
"oLanguage": { "sSearch": "Search all columns:",
},
"aoColumnDefs": [
{
"aTargets": [ 7 ], // Column to target
"mRender": function ( data, type, full ) {
// 'full' is the row's data object, and 'data' is this column's data
// e.g. 'full[0]' is the comic id, and 'data' is the comic title
return '' + data + '';
}
}
]
} );
$('#example tbody td img').live( 'click', function () {
var nTr = $(this).parents('tr')[0];
if ( oTable.fnIsOpen(nTr) )
{
/* This row is already open - close it */
this.src = "http://$url/DataTables-1.9.4/examples/examples_support/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "http://$url/DataTables-1.9.4/examples/examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
}
} );
} );
;
$name
Preamble
One line of text here
$name
A
B
C
D
E
F
G
H
I
Loading data from server
H
I
[/code]
This discussion has been closed.
Replies
[code]
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "XXXXXXXXX";
/* DB table to use */
$sTable = "XXXX";
/* Database connection information */
$gaSql['user'] = "XXXXXX";
$gaSql['password'] = "XXXXX";
$gaSql['db'] = "XXXXXXXX";
$gaSql['server'] = "localhost";
/* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
/* include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row[] = "";
$row = array();
$row[] = "";
for ( $i=0 ; $i
[/code]
Thank You