Column grouping (colspan, rowspan) and aoColumnDefs with bVisible as false

Column grouping (colspan, rowspan) and aoColumnDefs with bVisible as false

dimegdimeg Posts: 9Questions: 0Answers: 0
edited February 2011 in Bug reports
Just updated to 1.7.5 from early version. aoColumnDefs nice feature, but have problem here.

I have a table with column grouping (taken from examples page):

[code]



Rendering engine
Browser
Group


Platform(s)
Engine version
CSS grade




Trident
Internet
Explorer 4.0
Win 95+
4
X


....


[/code]

If i use no aoColumnDefs it works fine, but if I use such code:

[code]

$(document).ready(function() {
var columns = [
{"bVisible": false, "aTargets":["invisible"]}
];

$('#example').dataTable({
"aoColumnDefs": columns
});
});

[/code]

It removes not only "Rendering engine" but also and "Platform(s)". What can be wrong here? Can I overcome this issue without hucks? :)

Replies

  • hpachecohpacheco Posts: 19Questions: 0Answers: 0
    also having this problem (1.7.6)

    I'm using a complex header (row and colspan), whenever I use bVisible to hide a row it hides the target row and one of the rows in the bottom line

    has anyone encountered this problem before?
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Hi folks,

    I'm sorry to say that this is a limitation in the DataTables code for showing and hiding columns at the moment. You can get the same effect using the following code:

    [code]
    var oTable = $('#example').dataTable();
    oTable.fnSetColumnVis( 0, false );
    [/code]
    Basically the column visibility in DataTables doesn't cope with rowspan / colspan as it would be quite complicated to support that. I would like to, but haven't had the time to put this feature in yet (this limitation is noted in the fnSetColumnVis documentation: http://datatables.net/api#fnSetColumnVis ).

    Regards,
    Allan
  • david.dlccdavid.dlcc Posts: 7Questions: 0Answers: 0
    Try this (it worked for me):

    1) Define a css class to hide elements (name it as you wish):
    [code]
    invisible{
    display: none;
    }
    [/code]

    2) Apply the class to the colum instead of use bVisible
    [code]
    $('#example').dataTable({
    { //hide columns
    "sClass": "invisible",
    "aTargets": [ 0, ... ]
    }
    });
    [/code]
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Does that work in Chrome / Safari? I tried something similar recently and it didn't work in Chrome for me - but I didn't have time to try and get to the bottom of what what going on. All the other browsers seemed to cope fine with it - so something funny was happening...

    Allan
  • david.dlccdavid.dlcc Posts: 7Questions: 0Answers: 0
    I didn't try in Chrome and Safari, only in Firefox and IE.
  • hpachecohpacheco Posts: 19Questions: 0Answers: 0
    Tried it and it works fine in Chrome as well, thanks David!

    Hugo
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    That's good news going forward - I'll experiment some more, but this will make a number of things much easier if it does work :-)

    Allan
  • hpachecohpacheco Posts: 19Questions: 0Answers: 0
    edited April 2011
    Well I guess I spoke to soon..

    This seems to work when tables have complex headers but when they don't you can notice an empty column where the hidden column used to be.
    In some tables this only happens after changing the number of lines per page or after switching pages so I think it's caused by the way datatables redraws the table..

    edit: ok, maybe not a problem with datatables after all (sorry allan) as I did some testing and this is only happening in IE.
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    I've updated the 1.8 support for complex headers in 1.8.dev in the last few days, which it would be worth grabbing and using. It adds support for scrolling with complex headers (which I see you are using, so this is certainly needed) and now passes all unit tests. Beyond that, if you should show us what is happening that would be useful.

    Allan
  • hpachecohpacheco Posts: 19Questions: 0Answers: 0
    thanks Allan, I tried 1.8.dev and it's working fine now

    Hugo
This discussion has been closed.