colvis - column visibility

colvis - column visibility

GG Posts: 16Questions: 7Answers: 0

ISSUE 1
I have certain columns in the grid that dont show any header / column title.
For example a checkbox or print icon.
How to I modify the button for 'colvis' and 'csv' to only show columns / data where column title is present.
Note these columns are not hidden so using visibile isn't an option.

Please look at the attachment, you will notice how blank buttons are created.

new $.fn.dataTable.Buttons( table, {
buttons: [
{
extend: 'colvis',
columns: ':gt(0)'
}
]
} );

ISSUE 2
CSV / PDF does not export column with checkbox / radio button in them. How to get that working ?

q1.PNG 107.8K

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Try using the jQuery :empty selector:

    columns: ':not(:empty)'
    

    Allan

  • GG Posts: 16Questions: 7Answers: 0

    Thanks Allan.

    How do I get checkbox / radio / images to be in the column print / export

  • GG Posts: 16Questions: 7Answers: 0
    edited June 2016

    Also, when you export to pdf / print.. if teh grid is using YADCF individual column search .. the 'X' (used for clear search).. gets printed with it.

    Attached is the screenshot

    q2.PNG 10.1K
    q3.PNG 20.1K
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    How do I get checkbox / radio / images to be in the column print / export

    You would need to use a custom renderer. By default HTML is stripped from the output.

    if teh grid is using YADCF individual column search .. the 'X' (used for clear search).. gets printed with it.

    Unfortunately yes. This is a known limitation with the output. Again you would need to use a custom renderer (in this case for the header), since the output simply takes the text value of the header cell. That is something that will be resolved in a future release.

    Allan

  • GG Posts: 16Questions: 7Answers: 0

    Allan ,

    Issue with custom render for header is that column is passed as number ?
    There are no attributes or ID to change. there is no editing in here.

    format: {
    body: function ( data, column, row ) {
    // Strip $ from salary column to make it numeric
    return column === 5 ?
    data.replace( /[$,]/g, '' ) :
    data;
    }
    }

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Currently you need to get the nodes from the DOM I'm afraid. A change I'm going to put in soon will pass the nodes into those formatting methods to make this kind of thing easier. I'll post back when I've done that.

    Allan

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    I've just pushed a commit for this to git. Hopefully it will make it a little bit easier, although you will still need the formatting functions to get only the data you want.

    The nightly builds will be update to date in about 5 minutes time.

    Allan

  • GG Posts: 16Questions: 7Answers: 0

    Thank you Allan :)

This discussion has been closed.