redraw and fnOpen

redraw and fnOpen

gungnirgungnir Posts: 6Questions: 0Answers: 0
edited August 2012 in DataTables 1.9
hello alan. i loved datatables. and i need to use fnOpen function inside fnDrawCallback, cause im changing a value inside details of a row then i call fnStandingRedraw() but that details of row closed. here is my code (not all of it):

var nTr="";
$(document).ready(function() {
var oTable=$('#example').dataTable( {
"bProcessing": true,
"fnDrawCallback": function( oSettings ) {
if (nTr!="")
{
oTable.fnClose( nTr );
oTable.fnOpen( nTr ,'cce','details'); // -> it didnt happen. i used alert for ,fnisopen then it alerted "it is open" when i redraw it but it was closed. so i used fnClose first then i tried open again but it didnt work too.
}
},
"bServerSide": true,
"sAjaxSource": "siparisler_serversidesorter.php"
} );

$('#example tbody td img').live( 'click', function () {
nTr = $(this).parents('tr')[0]; // i took it var nTr variable
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(nTr),'details');
}
} );

});

function fnFormatDetails ( nTr )
{
// details from another page
var aData = oTable.fnGetData( nTr );
var sOut = '';
$.ajax({
url:'resources/siparis.php',
data:'order_id='+aData[1],
type:'POST',
success:function(result)
{
$(nTr).next().find('.opendiv').html(result);
}
})
return sOut;

}


function changestatus(newstatus,id,tel,changingrow){
// this is selecbox onchange function from inside details of rows
$.ajax({
url:'resources/update-order.php',
data:'id='+id+'&status='+newstatus+'&tel='+tel,
type:'POST',
success:function()
{
oTable.fnStandingRedraw();
}
})
}

Replies

  • gungnirgungnir Posts: 6Questions: 0Answers: 0
    i solved it myself . maybe this code helps someone. here it is:
    [code] var myinput;
    var listselected = new Array();
    var nTrs;
    var oTable=$('#example').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "siparisler_serversidesorter.php",
    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
    if(jQuery.inArray(aData[1],listselected) > -1) {
    $(nRow).attr('id','acik');
    }
    return nRow;
    },
    "fnDrawCallback": function( oSettings ) {
    nTrs = $("#example tbody tr");
    thisTable = $('#example').dataTable();
    nTrs.each(function() {
    myinput=$(this).attr('id');
    if(myinput=='acik'){
    $(this).find('.opendetails').attr("src","../images/details_close.png");
    thisTable.fnOpen( this,you can use text or go to a function(),"details" );
    }
    })
    }
    });

    $('#example tbody td').find('.opendetails').live( 'click', function () {
    var nTr = $(this).parents('tr')[0];
    var rowsdata=oTable.fnGetData( nTr );
    if ( oTable.fnIsOpen(nTr) )
    {
    /* This row is already open - close it */
    this.src = "../images/details_open.png";
    listselected.splice( $.inArray(rowsdata[1],listselected) ,1 );
    oTable.fnClose( nTr );
    }
    else
    {
    /* Open this row */
    this.src = "../images/details_close.png";
    listselected.push(rowsdata[1]);
    oTable.fnOpen( nTr,"you can use text or go to a function()",'details');
    }
    } );

    [/code]
This discussion has been closed.