fnStandingRedraw is not working

fnStandingRedraw is not working

lordoffriendslordoffriends Posts: 14Questions: 2Answers: 0
edited July 2011 in Bug reports
This function as given in the API is not working correctly for me.It does get called and executes perfectly.But the page doesn't remain on the same page when some row on it was deleted.
This is the code :-

$(document).ready(function() {
$('#example tbody tr').live('click', function (event) {

$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});

$(event.target.parentNode).addClass('row_selected');
aData = oTable.fnGetData(this); // get datarow
row = $(this).closest("tr").get(0);
});




/* Add a click handler for the delete row */
$('#delete').click( function() {
$.ajax({
type: "GET",
url: "<?php echo base_url(); ?>Test/DeleteData",
data: "id="+aData[0],
success: function(msg){
var anSelected = fnGetSelected( oTable );
oTable.fnDeleteRow( anSelected[0] );
oTable.fnDeleteRow(oTable.fnGetPosition(row));
oTable.fnStandingRedraw(oTable.fnSettings());
}
});
} );

/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();

for ( var i=0 ; i

Replies

  • allanallan Posts: 61,863Questions: 1Answers: 10,136 Site admin
    [code]
    oTable.fnDeleteRow( anSelected[0] );
    oTable.fnDeleteRow(oTable.fnGetPosition(row));
    oTable.fnStandingRedraw(oTable.fnSettings());
    [/code]

    You are redrawing the table 3 times there. http://datatables.net/api#fnDeleteRow - you need to tell delete row to not redraw the table.

    Allan
  • lordoffriendslordoffriends Posts: 14Questions: 2Answers: 0
    Modified the code.Still having the problem with fnStandingRedraw.This is the modified code.

    $(document).ready(function() {
    $('#example tbody tr').live('click', function (event) {

    $(oTable.fnSettings().aoData).each(function (){
    $(this.nTr).removeClass('row_selected');
    });

    $(event.target.parentNode).addClass('row_selected');
    aData = oTable.fnGetData(this); // get datarow
    row = $(this).closest("tr").get(0);
    });




    /* Add a click handler for the delete row */
    $('#delete').click( function() {
    //oTable.fnDraw(false);
    $.ajax({
    type: "GET",
    url: "<?php echo base_url(); ?>Test/DeleteData",
    data: "id="+aData[0],
    success: function(msg){
    oTable.fnDeleteRow(oTable.fnGetPosition(row),null,false);
    oTable.fnStandingRedraw(oTable.fnSettings());
    }
    });
    } );

    /* Get the rows which are currently selected */
    function fnGetSelected( oTableLocal )
    {
    var aReturn = new Array();
    var aTrs = oTableLocal.fnGetNodes();

    for ( var i=0 ; i
  • lordoffriendslordoffriends Posts: 14Questions: 2Answers: 0
    After deletion of ROW from DOM.the fnStandingRow gets called.But the settings are not persisted.Redirection to page 1 still remains.
  • lordoffriendslordoffriends Posts: 14Questions: 2Answers: 0
    This is what i did just now.
    oTable.fnStandingRedraw(oTable.fnSettings());
    oTable.fnDeleteRow(oTable.fnGetPosition(row),null,false);

    Now what happens is ...the deletion works for the first time.The DOM row gets deleted and page stays on the same page.But every second deletion on a page different from first page,the page is redirected to 1st page lol...Plz brother,i am waiting for the solution.Help me on this.I have to submit the project today.
This discussion has been closed.