colvis - column visibility
colvis - column visibility
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 ?
Answers
Try using the jQuery
:empty
selector:Allan
Thanks Allan.
How do I get checkbox / radio / images to be in the column print / export
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
You would need to use a custom renderer. By default HTML is stripped from the output.
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
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;
}
}
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
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
Thank you Allan