How to print Angular UI-Grid entire data?

后端 未结 1 855
清酒与你
清酒与你 2021-01-24 07:40

This is my code



        
相关标签:
1条回答
  • 2021-01-24 08:23

    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.

    0 讨论(0)
提交回复
热议问题