fnStandingRedraw?

fnStandingRedraw?

Ant248Ant248 Posts: 15Questions: 3Answers: 0

Hi Alan,

Bit confused how the fnStandingRedraw() function works.
I need to stop my table going to the first page on a redraw i've tried intializing with the table as so:

$(document).ready(function() {
        var table = $('#maintable').dataTable()
            table.fnStandingRedraw();
    $('#maintable').DataTable( {
                    "fnDrawCallback": function( oSettings ) {
            countertable++;
            console.log("adc", adc);
            if (countertable == 0){
                console.log("null");
                null;
            } else{
                if(adc == 0){
                fpart(1);    
                }else if(adc == 1){
                fpart(2);   
                }else if(adc == 2){
                fpart(3);    
                }
            }
            $( ".datepicker" ).datepicker( "destroy" );
            $( ".datepicker" ).datepicker({ dateFormat: "yy-mm-dd" });
        },
                "aoColumns": [
              null,
            { "orderDataType": "dom-text", "type": "string",  "sType": "date"},
            { "orderDataType": "dom-select" },
            { "orderDataType": "dom-select" },
            { "orderDataType": "dom-select" },
            { "orderDataType": "dom-select" },
            { "orderDataType": "dom-select" },
            { "orderDataType": "dom-select" },
            { "orderDataType": "dom-text-numeric" },
            { "orderDataType": "dom-text-numeric" },
            { "orderDataType": "dom-text-numeric" },
            { "orderDataType": "dom-text-numeric" },
            { "orderDataType": "dom-text-numeric" },
            { "orderDataType": "dom-text", "type": "numeric"  },
            { "orderDataType": "dom-text", "type": "numeric"  },
            { "orderDataType": "dom-text", "type": "numeric"  },
            { "orderDataType": "dom-text", "type": "numeric"  },
              null,
              null,
              null,
              null
                ]          
    } );
});

and calling at the end of function as so:

function addRow() {
adc = 0;
var table = $('#maintable').DataTable();
            var ip = table.page.info();
            addp = ip["page"];
id ++;
var place = id + 1;    

$('#maintable').dataTable().fnAddData( [
    '<span id="pla'+id+'">'+place+'</span>',
    '<input type="text" onkeyup="begin(this);" class="datepicker" id="ddate'+id+'" size="7"/>',
    '<select onchange="begin(this)"  id="count'+id+'"></select>',
    '<select onchange="begin(this)" id="assol'+id+'"><option value="liab">Buy</option><option value="asset">Sell</option></select>',
    '<select onchange="begin(this)" id="undt'+id+'"><option value="u3o8">U3O8</option><option value="inf">Inflation</option></select>',
    '<select onchange="begin(this)" id="loc'+id+'"><option value="cvd">ConverDyn</option><option value="cmh">Comurhex</option><option value="cam">Cameco</option><option value="les">LES</option><option value="ure">Urenco</option><option value="are">Areva</option><option value="gnf">GNF</option><option value="west">Westinghouse</option></select>',
    '<select onchange="begin(this)" id="prodt'+id+'"><option value="out">Outright</option><option value="call">Ceiling (Call)</option><option value="put">Floor (Put)</option></select>',
    '<select onchange="begin(this)" id="pricst'+id+'"><option value="float">Floating</option><option value="fix">Fixed</option><</select>',
    '<input onkeyup="begin(this);" type="text" id="fp'+id+'" size="1" />',
    '<input onkeyup="begin(this);" type="text" id="discp'+id+'" size="1" />',
    '<input onkeyup="begin(this);" class="number" type="text" id="sizeinf'+id+'" size="6" />',
    '<input onkeyup="begin(this);" type="text" id="strike'+id+'" size="1" />',
    '<input type="text" class="datepicker" id="besd'+id+'" size="7" />',
    '<span id="um'+id+'"></span>',
    '<span id="av'+id+'"></span>',
    '<span id="tl'+id+'"></span>',
    '<span id="pnl'+id+'"></span>',
    '<span id="suo'+id+'"></span>',
    '<span id="sr'+id+'"></span>',
    '<span id="si'+id+'"></span>',
    '<span id="sv'+id+'"></span>'
     ] );
var table = $('#maintable').dataTable()
table.fnStandingRedraw();
}

still going back to my first page :(

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Don't use that function - it is legacy and I personally haven't tested it. Just use the draw() API method that is built into DataTables. Pass false as the parameter to do a standing redraw as its documentation describes.

    Allan

  • Ant248Ant248 Posts: 15Questions: 3Answers: 0

    Thanks very much Allan!

    It works on most my functions how ever to use it with this function:

    function addRow() {
    adc = 0;
    var table = $('#maintable').DataTable();
                var ip = table.page.info();
                addp = ip["page"];
    id ++;
    var place = id + 1;    
    
    $('#maintable').dataTable().fnAddData( [
        '<span id="pla'+id+'">'+place+'</span>',
        '<input type="text" onkeyup="begin(this);" class="datepicker" id="ddate'+id+'" size="7"/>',
        '<select onchange="begin(this)"  id="count'+id+'"></select>',
        '<select onchange="begin(this)" id="assol'+id+'"><option value="liab">Buy</option><option value="asset">Sell</option></select>',
        '<select onchange="begin(this)" id="undt'+id+'"><option value="u3o8">U3O8</option><option value="inf">Inflation</option></select>',
        '<select onchange="begin(this)" id="loc'+id+'"><option value="cvd">ConverDyn</option><option value="cmh">Comurhex</option><option value="cam">Cameco</option><option value="les">LES</option><option value="ure">Urenco</option><option value="are">Areva</option><option value="gnf">GNF</option><option value="west">Westinghouse</option></select>',
        '<select onchange="begin(this)" id="prodt'+id+'"><option value="out">Outright</option><option value="call">Ceiling (Call)</option><option value="put">Floor (Put)</option></select>',
        '<select onchange="begin(this)" id="pricst'+id+'"><option value="float">Floating</option><option value="fix">Fixed</option><</select>',
        '<input onkeyup="begin(this);" type="text" id="fp'+id+'" size="1" />',
        '<input onkeyup="begin(this);" type="text" id="discp'+id+'" size="1" />',
        '<input onkeyup="begin(this);" class="number" type="text" id="sizeinf'+id+'" size="6" />',
        '<input onkeyup="begin(this);" type="text" id="strike'+id+'" size="1" />',
        '<input type="text" class="datepicker" id="besd'+id+'" size="7" />',
        '<span id="um'+id+'"></span>',
        '<span id="av'+id+'"></span>',
        '<span id="tl'+id+'"></span>',
        '<span id="pnl'+id+'"></span>',
        '<span id="suo'+id+'"></span>',
        '<span id="sr'+id+'"></span>',
        '<span id="si'+id+'"></span>',
        '<span id="sv'+id+'"></span>'
         ] );
    table.draw(false);
    }
    

    I see its due to all the other functions using $('#maintable').DataTable().draw(false);
    however the add row uses the $('#maintable').dataTable()
    Did i use an old add row function ? :)

  • Ant248Ant248 Posts: 15Questions: 3Answers: 0

    aha yeah sorry i see now, will use the row.add()
    Take it easy Alan !
    I dunno how you get through all these questions :)

This discussion has been closed.