Anyone get fnAddTr and colvis to work together?

Anyone get fnAddTr and colvis to work together?

fecundfecund Posts: 15Questions: 0Answers: 0
edited November 2011 in General
When I use AddTr it doesn't seem to get the visibility. It must overwrite the display html that gets used on redraw? Anyone get these two to work together? I'm using AddTr because I have classes and lots of other data for each row I insert into the table.

Replies

  • fecundfecund Posts: 15Questions: 0Answers: 0
    edited November 2011
    I did this but it's probably not the best way:

    [code]
    var iIndex = this.oApi._fnAddData( oSettings, aData );
    var numcols = nTds.length;
    var j = -1;
    for ( var i=0 ; i
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Yup it looks like fnAddTr doesn't take into account column visibility. Thanks for flagging that up I'll take a look at it as soon as I can.

    Allan
  • fecundfecund Posts: 15Questions: 0Answers: 0
    Can you also make a fnUpdateTr as well?
  • fecundfecund Posts: 15Questions: 0Answers: 0
    This hack was working great until recently, I think until after I added a custom filter.

    [code]
    var numcols = nTds.length;
    var j = -1;
    for ( var i=0 ; i
  • fecundfecund Posts: 15Questions: 0Answers: 0
    When I comment out the adding of the TR back into the DT array:

    [code]//oSettings.aoData[ iIndex ].nTr = nTr;[/code]

    everything works right, even the hidden/visible columns, but of course I lose all my classes and stuff.
  • fecundfecund Posts: 15Questions: 0Answers: 0
    edited November 2011
    The code works well with no columns hidden, but if I do it breaks.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    I've added it to my to-do list to modify fnAddTr to take account of visible and hidden columns, and also to have a look at fnUpdateTr. If you'd like this work prioritised, hit the support link at the top of the page :-)

    Allan
  • fecundfecund Posts: 15Questions: 0Answers: 0
    Props on the plug ;-) The OCD in me wants to fix it myself, so now its a crisis of money vs. sanity.
  • fecundfecund Posts: 15Questions: 0Answers: 0
    I may have gotten it?
    [code]
    /* Add the data and then replace DataTable's generated TR with ours */
    var numcols = nTds.length;
    var iIndex = this.oApi._fnAddData( oSettings, aData );
    var j = -1;
    for ( var i=0 ; i
  • fecundfecund Posts: 15Questions: 0Answers: 0
    This appears to be working. hooray!
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Nice one! Looks good to me and thanks for sharing your code with us :-)

    Allan
This discussion has been closed.