在kendo ui中将所有网格页面导出为pdf不起作用

时间:2015-07-10 09:12:52

标签: asp.net-mvc-4 kendo-ui kendo-grid

<style>
        /*
            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 and pager during export */
        .k-pdf-export .k-grid-toolbar,
        .k-pdf-export .k-pager-wrap {
            display: none !important;
        }
</style>

@section pageBody {
        @using (Html.BeginForm("IndexListPage", "AccntGroup", FormMethod.Post))
        {
            <!-- Query Panel -->
            <div id="queryPanel" class="containerDiv100">
                <table class="table-thinborder100">
                    <tr>
                        <!-- Showing title of the page-->
                        <td class="ob-pagetitle">
                            <span>@ViewBag.Title</span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span></span>
                        </td>
                    </tr>
                </table>
                <div style="float:right;margin-right:13px">
                    @(Html.Kendo().Button()
                                  .Name("Back")
                                  .HtmlAttributes(new { @class = "width100", style = "float:right", type = "Button" })
                                  .Content("Back to List Page")
                                  .Events(e => e.Click("Back"))
                    )
                </div>
                <br>
                <br>

            </div>
            <div id="queryResult" class="containerDiv100">
                <div id="DIV_Line05" class="colLine" style="float: right">
                    <div id="DIV_Grid" class="col100">
                        @(Html.Kendo().Grid<AccntGroupModel>()
                            .Name("KendoGrid1")
                            .Columns(columns =>
                            {
                                // Creating a column displays as hyperlink
                                columns.Bound(m => m.AccntGroupName).Filterable(true).Title("Account Group Name").Width("30%").HtmlAttributes(new { @style = "font-size:x-small" });
                                columns.Bound(m => m.AccntGroupCode).Filterable(true).Title("Code").Width("20%").HtmlAttributes(new { @style = "font-size:x-small" });
                                columns.Bound(m => m.V_AccntGroupType).Filterable(true).Title("Type").Width("20%").HtmlAttributes(new { @style = "font-size:x-small" });
                               columns.Bound(m => m.V_AccntGroupSubTypeLabel).Filterable(true).Title("Sub Type").Width("20%").HtmlAttributes(new { @style = "font-size:x-small" });
                            })
                            .ToolBar(tools => tools.Pdf())
                            .Pdf(pdf => pdf
                                .AllPages()
                                .Title("Bizsense Solutions Pvt. Ltd. ")
                                .FileName("Kendo UI Grid Export.pdf")
                                .ProxyURL(Url.Action("Pdf_Export_Save", "AccntGroup"))
                            )
                            .Pageable()
                            .HtmlAttributes(new { @class = "width100" })
                            .Scrollable(config => config.Enabled(true))        
                            .Sortable()        
                            .DataSource(source => source
                            .Ajax()
                            .PageSize(10)            
                            .Model(model =>
                            {
                               model.Id(m => m.AccntGroupId);
                            })
                            .Read(read => read.Action("Read", "AccntGroup", new { area = "ListPage" }))
                        )
                     )
                    </div>
                </div>
            </div>
        }
        <script type="text/javascript">
            $(document).ready(function () {
                $("#KendoGrid1").kendoGrid({
                    pageSize: 10,
                    height: 350,         
                });
            });
            function Back()
            {
                var ActionUrl = "@Url.Action("ListPageMenuIndex", "Menu", new { area = "Menu" })"
                $.ajax({
                    url: ActionUrl,
                    success: function (result) {
                        window.location.href="@Url.Action("ListPageMenuIndex", "Menu", new { area = "Menu" })"
                    }
                });
            }
        </script>
    }

控制器:

[HttpPost]
public ActionResult Pdf_Export_Save(string contentType, string base64, string fileName)
{
    var fileContents = Convert.FromBase64String(base64);
    return File(fileContents, contentType, fileName);
}

所有页面都没有输出到PDF格式。 它适用于excel的方式.. allpages()不适用于pdf。人们建议添加那个样式部分..但仍然没有工作.. 标题都没有设定.. 我刚刚更新了我的telerik ..我需要添加任何参考或脚本或链接吗?

0 个答案:

没有答案
相关问题