[v1.6.2] hidden row information in table with new query

[v1.6.2] hidden row information in table with new query

pakypaky Posts: 106Questions: 0Answers: 0
edited April 2010 in General
Hi Allan, how can customize 'fnFormatDetails' function for show a new set of dynamic data ?

thanks

Replies

  • pakypaky Posts: 106Questions: 0Answers: 0
    Can I insert ajax procedure in fnFormatDetails function ?

    [code]
    function fnFormatDetails ( nTr )
    {
    var sOut;
    var aData = Table_list_project.fnGetData( nTr );
    $.ajax({
    type:"POST",
    url: 'includes/__ajax_gear/_get_details_progetti.php',
    cache: false,
    data:'',
    success: function(msg)
    {
    sOut = msg;
    }
    });

    return sOut;
    }
    [/code]
  • psjandhyalapsjandhyala Posts: 6Questions: 0Answers: 0
    Hi Paky,

    i just implemented in this concept in my project. Please do the following steps.

    In the success call back method, please add following line
    [code]oTable.fnOpen( nTr, sOut, 'details' );[/code]

    and inside "Add event listener for opening and closing details"

    [code]//oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );[/code]

    Regards
    psjandhyala
  • pakypaky Posts: 106Questions: 0Answers: 0
    Thanks very mch psjandhyala, I feel now and will update progress !! ;)

    Paky
  • pakypaky Posts: 106Questions: 0Answers: 0
    ehm ... psjandhyala I try it but nothing happened !!
    Here changed code :
    [code]

    /* Formating function for row details */
    function fnFormatDetails ( nTr )
    {

    var aData = Table_list_project.fnGetData( nTr );

    $.ajax({
    type:"POST",
    url: 'includes/__ajax_gear/_get_details_progetti.php',
    cache: false,
    data:'',
    //data:"JS={\"jspro_id\":\""+new_id+"\",\"jspro_desc\":\""+new_desc+"\",\"jsun_id\":\""+unique_id+"\"}",
    success: function(msg)
    {
    sOut = msg;
    //your advice add this line here
    Table_list_project.fnOpen( nTr, fnFormatDetails(nTr), 'details' );

    }
    });

    }

    /* Event handler function */
    function fnOpenClose ( oSettings )
    {

    $('td img', Table_list_project.fnGetNodes() ).each( function () {
    $(this).click( function () {
    var nTr = this.parentNode.parentNode;
    if ( this.src.match('details_open') )
    {
    // This row is already open - close it
    this.src = "images/icons/details_close.png";
    // fnClose doesn't do anything for server-side processing - do it ourselves :-)
    var nRemove = $(nTr).next()[0];
    nRemove.parentNode.removeChild( nRemove );
    }
    else
    {
    // Open this row
    this.src = "images/icons/details_open.png";
    //your advice (comment line)--->Table_list_project.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
    }
    } );
    } );

    }
    [/code]

    thanks
  • psjandhyalapsjandhyala Posts: 6Questions: 0Answers: 0
    edited April 2010
    Hi Paky,

    In the AJAX success call back method please pass your response text as follow.

    correct way of code is
    [code]
    success: function(msg){
    sOut = msg;
    //we have to pass our response text as follow, Here I am passing sOut variable
    //we should not pass fnFormatDetails(nTr)
    Table_list_project.fnOpen( nTr, sOut , 'details' );
    }
    [/code]

    This will solve your problem.

    Regards
    Psjandhyala
  • pakypaky Posts: 106Questions: 0Answers: 0
    Hi Psjandhyala, I try with
    [code]
    Table_list_project.fnOpen( nTr, sOut , 'details' );
    [/code]


    on first click event nothing happens .... on second click this error

    Firebug Error:
    > nRemove is undefined



    thanks
  • pakypaky Posts: 106Questions: 0Answers: 0
    paste here final code :


    [code]
    /* Formating function for row details */
    function fnFormatDetails ( nTr )
    {
    var aData = Table_list_project.fnGetData( nTr );

    $.ajax({
    type:"POST",
    url: 'includes/__ajax_gear/_get_details_progetti.php',
    cache: false,
    data:'',
    //data:"JS={\"jspro_id\":\""+new_id+"\",\"jspro_desc\":\""+new_desc+"\",\"jsun_id\":\""+unique_id+"\"}",
    success: function(msg)
    {
    sOut = msg;
    Table_list_project.fnOpen( nTr, sOut, 'details' );

    }
    });
    }

    /* Event handler function */
    function fnOpenClose ( oSettings )
    {

    $('td img', Table_list_project.fnGetNodes() ).each( function () {
    $(this).click( function () {
    var nTr = this.parentNode.parentNode;
    if ( this.src.match('details_open') )
    {
    // This row is already open - close it
    this.src = "images/icons/details_close.png";
    // fnClose doesn't do anything for server-side processing - do it ourselves :-)
    var nRemove = $(nTr).next()[0];
    nRemove.parentNode.removeChild( nRemove );
    }
    else
    {
    // Open this row
    this.src = "images/icons/details_open.png";
    //Table_list_project.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
    }
    } );
    } );

    }

    // Data.TABLE

    Table_list_project=$('#data_tbl_progetti_storico').dataTable
    ({
    "bProcessing": true,
    "bServerSide": true,
    "bAutoWidth": false,
    "bSort":false,
    "sAjaxSource": "includes/dfile.php",
    "bStateSave": false,
    "bJQueryUI": false,
    "sPaginationType": "full_numbers",

    "fnServerData": function ( sSource, aoData, fnCallback ) {
    aoData.push( { "name": "id_unico", "value": id_unico });
    //aoData.push( { "name": "super_add", "value": rnd_cache_damn });
    $.ajax( {
    "dataType": 'json',
    "type": "GET",
    "url": sSource,
    "data": aoData,
    "success": fnCallback
    } );
    },

    "fnDrawCallback": fnOpenClose

    });
    [/code]

    thanks
    paky
  • pakypaky Posts: 106Questions: 0Answers: 0
    Someone get an idea ? For show row details from ajax calling (then another query .php) ?!

    thanks all
  • emeraldemerald Posts: 5Questions: 0Answers: 0
    Hi,
    had the same problem, thanks to your help i got it to work within minutes :)

    [code]
    function fnFormatDetails(nTr) {

    var aData = oT.fnGetData(nTr);
    var sOut;

    $.ajax({
    url: 'yourServiceURL',
    data: '{}',
    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    dataType: 'json',
    success: function (result) {
    sOut = 'Detailed information: ' + result;
    oT.fnOpen(nTr, sOut, 'details');
    }
    });
    }
    [/code]
This discussion has been closed.