TableTools with serverside processing

TableTools with serverside processing

josys64josys64 Posts: 4Questions: 0Answers: 0
edited November 2009 in Plug-ins
Hi,

first, thanks Alan for this great job.

My question is, i'm using dataTables with serverside processing , works perfect.
I have 50 000 rows, i use ajax processing, like this :
[code]jQuery('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sDom": 'T<"clear">lfrtip',
"sPaginationType": "full_numbers",
"sAjaxSource": "stat-export/stat_getdata.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
jQuery.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}

} );[/code]

With TableTools it's almost good , the only thing is when i try to save as csv (or xls) , it's saving only the data present in the DOM (Display records), is there a way to save all data at once (50 000) ?

Replies

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin
    HI josys64,

    As you have noticed with server-side processing, TableTools is more focused on the client-side part. One reason for this is that there is a limit to the amount of data that can be sent of the JS / Flash bridge - which your 50'000 records would almost certainly hit.

    As such, what I think you'll need to do is modify TableTools to send a request to the server to create and download a file, rather than having Flash do it. It should be a fairly simple process to hack TableTools to send the required XHR and then output the file which the browser will save.

    Hope this helps,
    Allan
  • josys64josys64 Posts: 4Questions: 0Answers: 0
    Hi Allan,

    thanks for your reply.

    Which function should i have to hack in TableTools.js , is fnGetDataTablesData ?
  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin
    Hi josys64,

    Possibly fnGetDataTableData - you could make an XHR request to get everything using that - and that would do the trick for all of the functions, if you want to use the Flash interface to create and save the files. But as I noted, I think you'll run into problems with this. Probably better to send an XHR from fnFeatureSaveXLS or fnFeatureSaveCSV to request that the server create the required file.

    Regards,
    Allan
  • EmanSJEmanSJ Posts: 4Questions: 0Answers: 0
    hi josys64,

    Could you please share codes or files with me, cause I'm focusing tabletools (exporting csv, xls, pdf) in server side.

    Thanks.
  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin
    Have a look at the 'download' plug-in for TableTools: http://datatables.net/extras/tabletools/plug-ins

    Allan
  • avismiles4uavismiles4u Posts: 1Questions: 0Answers: 0
    hello sir. i am new to php,datatables and table tools. i too want to save the entire table. but what is the code to write in generate_pdf.php?
  • shakeelnyshakeelny Posts: 1Questions: 0Answers: 0
    hi allan,

    im new to programming and table tools.i am using server side php could you please post the sample js code and php code. with the table tools alt initiation... thnks
  • abhi05144abhi05144 Posts: 7Questions: 0Answers: 0
    Can anyone please post the sample code/reference for server side save as option.
    If possible in JAVA.
  • intelligointelligo Posts: 1Questions: 0Answers: 0
    Hi All; I am trying to use the TableTools with serverside pipelining. Is it not supported without doing everything client side Allan?

    Is there any javascript only version of this?
  • anilmcmtanilmcmt Posts: 9Questions: 0Answers: 0
    <?php
    include_once("../conf.php");//configure file


    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * 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)
    */
    // $ratelistquery = mysql_query("select * from cc_ratecard where id_trunk !='-1' limit 0,50") or die("error in something cc_ratecard");
    $aColumns = array( 'id', 'id_trunk', 'dialprefix', 'destination', 'buyrate','buyrateinitblock','buyrateincrement','Grace', 'id' );

    /* Indexed column (used for fast and accurate table cardinality) */
    $sIndexColumn = "id";

    /* DB table to use */
    $sTable = "cc_ratecard";



    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * If you just want to use the basic configuration for DataTables with PHP server-side, there is
    * no need to edit below this line
    */

    /*
    * Local functions
    */
    function fatal_error ( $sErrorMessage = '' )
    {
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( $sErrorMessage );
    }




    /*
    * 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
  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin
    As I said earlier and in other discussions, fundamentally TableTools' client-side processing is not compatible with server-side processing. The whole point of server-side processing is that the full data set is at the server and not the client, while if you want to use TableTools for a full export, you need the full data set on the client-side. That's a design decision you need to make - which you want.

    Allan
This discussion has been closed.