This is a migrated thread and some comments may be shown as answers.

RowTemplate, Export PDF, Hide Column

2 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gregg
Top achievements
Rank 1
Gregg asked on 30 Jan 2018, 05:14 PM

The last column of my grid contains some custom buttons.  The grid itself is built using a row template. When I export to PDF, I need to hide the last column.  I followed the instruction on how to use the PdfExport event to hide the column and then re-display it on the promise.done, but couldn't get it to hide the column on the PDF.  To see where I was going wrong, I added the code snippet below to the Basic usage example for the Grid and it worked as expected.  However, when I modified the Row template example for the Grid, it didn't hide the column on the PDF.

        toolbar: ["pdf"],
        pdf: {
            allPages: true,
            avoidLinks: true,
            paperSize: "A4",
            margin: { top: "2cm", left: "1cm", right: "1cm", bottom: "1cm" },
            landscape: true,
            repeatHeaders: true,
            scale: 0.8
        },
        pdfExport: function(e) {
            var grid = $("#grid").data("kendoGrid");
            grid.hideColumn(0);
 
            e.promise.done(function() {
             grid.showColumn(0);
            });
        },

 

I was wondering if this functionality (i.e. hide column on Pdf Export) is not supported with row templates, or if I'm just doing something stupid (more than likely the case)?

Thanks, Gregg

 

2 Answers, 1 is accepted

Sort by
0
Gregg
Top achievements
Rank 1
answered on 30 Jan 2018, 08:36 PM

I was able to accomplish what I desired by switching from a row template to client templates on the columns.  I would be curious to know if row templates support hiding columns during a PDF export.

Thanks again, Gregg

0
Stefan
Telerik team
answered on 01 Feb 2018, 07:50 AM
Hello, Gregg,

I'm glad that the issue is resolved.

In general, the issue occurs in the first place because when the row template is used the Grid does not have an actual column separation as the row is treated as one. This is creating a scenario and in which the Grid hideColumn method will hide data when the index 0 is used and non of the data if index bigger then 0 is used. This is a specific of the hideColumn method with a combination of row template.

I will discuss this with the developers' team and we will add a note in the documentation to ensure that this will not be misleading in the future.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Gregg
Top achievements
Rank 1
Answers by
Gregg
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or