Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82141

[SOLVED]Feature not working with server side processing

$
0
0
Hi all,

As I was posting my question on this forum and didn't get any answer.

I was debugging a bit and I think that hiding a row example is not working when I am using a server side processing.

/* Formating function for row details */
function fnFormatDetails ( oTable, nTr )
{
    var aData = oTable.fnGetData( nTr );
    var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
    sOut += '<tr><td>Rendering engine:</td><td>'+aData[1]+' '+aData[4]+'</td></tr>';
    sOut += '<tr><td>Link to source:</td><td>Could provide a link here</td></tr>';
    sOut += '<tr><td>Extra info:</td><td>And any further details here (images etc)</td></tr>';
    sOut += '</table>';
      
    return sOut;
}
 
$(document).ready(function() {
     
    /*
     * Insert a 'details' column to the table
     */
    var nCloneTh = document.createElement( 'th' );
    var nCloneTd = document.createElement( 'td' );
    nCloneTd.innerHTML = '<img src="../images/details_open.png">';
    nCloneTd.className = "center";
      
    $('#jphit thead tr').each( function () {
        this.insertBefore( nCloneTh, this.childNodes[0] );
    } );
    /**** Possible problem****/  
    $('#jphit tbody tr').each( function () {
        this.insertBefore(  nCloneTd.cloneNode( true ), this.childNodes[0] );
    } );
     /*************************/
    var oTable=$('#jphit').dataTable( {
             "sDom": 'T,C<"clear">lfrtip',
             "oTableTools": {
            "sSwfPath": "swf/copy_csv_xls_pdf.swf"
        },
             "oColVis": {
             "buttonText": "Extend table",
            "activate": "mouseover"
        },
        "aoColumnDefs": [
      { //"bVisible": false, "aTargets": [ 0 ],
        "bSortable": false, "aTargets": [ 0 ]     }
    ],
            "aaSorting": [[1,'asc']],
            "bProcessing": true,
            "bServerSide": true,
            "sPaginationType": "full_numbers",
            "sScrollY": "350px",
            "bDeferRender": true,
            "sAjaxSource": "increment_table.php"
        } );
         
    
      
    /* Add event listener for opening and closing details
     * Note that the indicator for showing which row is open is not controlled by DataTables,
     * rather it is done here
     */
    $('#jphit 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 = "../images/details_open.png";
            oTable.fnClose( nTr );
        }
        else
        {
            /* Open this row */
            this.src = "../images/details_close.png";
            oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
        }
    } );
 
    } );

Problem is occurring when the td needs to be inserted in the tbody.
My header is show correctly and I have one empty spot in the first cell on the left.
But when data is coming from ajax call then everything is mixed. For example I should get a empty spot on the first cell on the leeft side and I am getting a empty cell on my right side.

I will give you a link to my previously posted question here on this forum but with no luck I must say.


My question is how to use this function if I am using a server side processing?

LINK: http://datatables.net/forums/discussion/11227/please-help-hidden-row-example-is-not-drawing-rows#Item_5

Viewing all articles
Browse latest Browse all 82141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>