How to print Angular UI-Grid entire data?

别说谁变了你拦得住时间么 提交于 2019-12-02 04:32:00

Hint 1:

If you refer in how to print with ui-grid, the ui-grid website indicates help at Exporting Data, where you can export your data from the grid menu.

Hint 2

If you want to manage exporting to Pdf in a custom menu item, you have to define something like this:

$scope.gridOptions = {
    gridMenuCustomItems = [ 
       {
            title: 'Exporting as PDF',
            action: function ($event) {

                var exportColumnHeaders = uiGridExporterService.getColumnHeaders(this.grid, uiGridExporterConstants.ALL);
                var exportData = uiGridExporterService.getData(this.grid, uiGridExporterConstants.ALL, uiGridExporterConstants.ALL, true);
                var docDefinition = uiGridExporterService.prepareAsPdf(this.grid, exportColumnHeaders, exportData);

                if (uiGridExporterService.isIE() || navigator.appVersion.indexOf("Edge") !== -1) {
                  uiGridExporterService.downloadPDF(this.grid.options.exporterPdfFilename, docDefinition);
                } else {
                  pdfMake.createPdf(docDefinition).download();
                } 
            },
            order: 2
        }
}

Note: You have to include reference to this at your angular controller: uiGridExporterService, uiGridExporterConstants

Hint 3

If you have any trouble printing more than 500 rows, there is a bug in the pdfmake.js library that is used by the ui-grid component. For this, you have a workaround at github. You have extra info at this github issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!