• Resolved jstigerman

    (@jstigerman)


    I need help! I’ve been searching the forum for hours and experimenting with commands that were related. I can answer yes to all your questions in Important: Please read this, before asking for support with TablePress! The pluging works fine. The CSS I found works fine. I just need to be able to do one thing – print only the visible columns.

    I activated DataTable Buttons. [table id=3 datatables_buttons=”colvis,copy,csv,excel,pdf,print” /]
    I have seven columns. Two are hidden using CSS. I used the CSS so the columns could be searched without being visible. I spent hours on the forum searching for a code that I could add to the ‘Custom Commands’ section. I found several, but none of them worked. I tried modifying the code, but I could not get any of the modifications to work.

    Here’s some attempts.

    Placed in ‘Custom Commands’ section. This did not work. I removed it.

    “buttons”: [
    {
    “extend”: “copyHtml5”,
    “exportOptions”: {
    “columns”: [ 0, “:visible” ]
    }
    },
    {
    “extend”: “excelHtml5”,
    “exportOptions”: {
    “columns”: “:visible”
    }
    },
    {
    “extend”: “pdfHtml5”,
    “exportOptions”: {
    “columns”: [ 1, 4, 5, 6, 7 ]
    }
    },
    “colvis”
    ]

    Placed in ‘Custom Commands’ section. This did not work either. It eliminated all the buttons except for PDF, and that did’t work. I read that @sagirish had figured out where he went wrong with this code, but there was no further comment about it that I could find.

    “buttons”: [

    {
    “extend”: “pdfHtml5”,
    “exportOptions”: {
    “columns”: [ 1,4,5,6,7 ]
    }
    }
    ]

    I tried this [table id=3 datatables_buttons=”pdf,print” datatables_buttons_exclude_columns=2,3 /] along with some variations

    None of them worked.

    Is there a simple solution to print only the visible columns?

    Thank you very much for your assistance. This is a great plugin. If I can get it to work as needed, I will be making a donation.

    Jason

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Just so that I understood correctly:
    The table has 7 columns, from which you only want to show 5 one the page (2 are successfully hidden with CSS code), and you only want those 5 to appear when someone clicks the “Print” button?
    For that, please try using this “Custom Command”:

    "buttons": [
    	"colvis",
    	"copy",
    	"csv",
    	"excel",
    	"pdf",
    	{
    		"extend": "print",
    		"exportOptions": {
    			"columns": [ 0, 3, 4, 5, 6 ]
    		}
    	}
    ]

    (You were very close already, from what I can see – you just haven’t modified the “Print” button, but only the other buttons. In addition, the numbers for the columns are counted starting with 0 in this type of code.)

    Regards,
    Tobias

    Thread Starter jstigerman

    (@jstigerman)

    Hi Tobias:

    Thank you so much for the quick reply. Unfortunately the code you forwarded did not work. However, it did give me enough information to modify it. Here’s what I have.

    “buttons”: [
    {
    “extend”: “print”,
    “exportOptions”: {
    “columns”: [ 0, 3, 4, 5, 6 ]
    }
    },

    {
    “extend”: “pdf”,
    “exportOptions”: {
    “columns”: [ 0, 3, 4, 5, 6 ]
    }
    }
    ]

    This hides the 2nd and 3rd columns in the Print and PDF options. Just what I needed. I appreciate it. I will get off a donation. Great program! I’ll give you 5 stars.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Print Only Visible Columns’ is closed to new replies.