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

How export a grid to pdf with "ClientFooterTemplate" but without "tool bar"

1 Answer 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 15 Apr 2016, 06:30 PM

I want export information from a Grid mvc to PDF without the tool bar but with the Client FooterTemplate, because, I  have the total amount about all rows  here

this is mi full code

 

<link href="~/Content/kendo/2016.1.112/kendo.common-material.min.css" rel="stylesheet" />
<link href="~/Content/kendo/2016.1.112/kendo.material.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.4.0/jszip.min.js"></script>
<script src="~/Scripts/kendo/2016.1.112/jquery.min.js"></script>
<script src="~/Scripts/kendo/2016.1.112/kendo.all.min.js"></script>
<script src="~/Scripts/kendo/2016.1.112/kendo.aspnetmvc.min.js"></script>

<style>
    #grid .k-grid-content {
        height: 283px !important;
    }

    #grid > div.k-grid-footer > div > table > tbody > tr > td:nth-child(6) {
        text-align: right;
    }

    #grid > div.k-grid-footer > div > table > tbody > tr > td:nth-child(7) {
        text-align: right;
    }

    /*
        Use the DejaVu Sans font for display and embedding in the PDF file.
        The standard PDF fonts have no support for Unicode characters.
    */
    .k-grid {
        font-family: "DejaVu Sans", "Arial", sans-serif;
    }

    /* Hide the Grid header during export */ 
    /*.k-pdf-export .k-grid-toolbar,
    .k-pdf-export .k-pager-wrap*/
    .k-pdf-export .k-grid-toolbar
    {
        display: none;
    }
    
</style>
@{
    Layout = null;
}

<div id="transactions">
    @(Html.Kendo().Grid<Account.ViewModels.AccountManagement.AccountingViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.CompanyName);
        columns.Bound(p => p.ContractDescription);
        columns.Bound(p => p.ConceptType);
        columns.Bound(p => p.MovementDate).Title("Date").Format("{0:MMMM dd yyyy}");
        columns.Bound(p => p.Billing).Title("Invoice Number");
        columns.Bound(p => p.PaidFlag).Title("Status").ClientFooterTemplate("Total");
        columns.Bound(p => p.Paid).Title("Amount").Format("{0:c}").HtmlAttributes(new { style = "text-align:right" })
        .ClientFooterTemplate("#= kendo.format('{0:c}', sum) #");
    })
    .ToolBar(tools =>
    {
        tools.Excel();
        tools.Pdf();
    })
    .Excel(excel => excel.FileName("Transaction.xlsx").Filterable(true).ProxyURL(Url.Action("ExcelExportTransactions", "Accounting")))
    .Pdf(pdf=>pdf.AllPages()
    .FileName("Transactions.pdf")
    .Margin(0,1,100,1)
    .ProxyURL(Url.Action("PdfExportTransactions", "Accounting")))
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Sort(sort => sort.Add("CompanyName").Ascending())
        .ServerOperation(true)
        .Model(model => model.Id(p => p.MovementID))
                .Read(read => read.Action("ReadTransactions", "Accounting"))
        .Aggregates(a => { a.Add(p => p.Paid).Sum(); })


     )
    )
</div>

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 19 Apr 2016, 10:23 AM
Hello Luis,

Thank you for contacting us.

To achieve the desired functionality you need to use following css styles:
/* Hide the Grid header during export */
    /*.k-pdf-export .k-grid-toolbar,
    .k-pdf-export .k-pager-wrap*/
    .k-pdf-export .k-grid-toolbar {
        display: none;
    }
    .k-pdf-export #grid .k-grid-content {
        height: 100% !important;
    }

The second one:
.k-pdf-export #grid .k-grid-content {
        height: 100% !important;
    }
will override the custom style which you use:
#grid .k-grid-content {
        height: 283px !important;
    }
which is the reason footer template to not be shown.

Please give it try and let me know if it helps you.

Looking forward for your reply.

Regards,
Radoslav
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Luis
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or