angular-ui / ui-grid

UI Grid: an Angular Data Grid
http://ui-grid.info
MIT License
5.39k stars 2.47k forks source link

Having an Issue With Exporting? #4268

Open mikehuebner opened 9 years ago

mikehuebner commented 9 years ago

Hey everyone! Just wanted to bring this up since I'm having an issue. Its working on one project but not another and I don't understand why. Here is my return information:

From UI Grid pdfExport on line 17425 after its been converted to the doc definition format.

{
    "pageOrientation": "landscape",
    "pageSize": "LETTER",
    "content": [{
        "style": "tableStyle",
        "table": {
            "headerRows": 1,
            "widths": [71.54471544715447, 71.54471544715447, 71.54471544715447, 71.54471544715447, 71.54471544715447, 71.13821138211382, 71.13821138211382],
            "body": [
                [{
                    "text": null,
                    "style": "tableHeader"
                }, {
                    "text": "Date",
                    "style": "tableHeader"
                }, {
                    "text": "Enter",
                    "style": "tableHeader"
                }, {
                    "text": "Exit",
                    "style": "tableHeader"
                }, {
                    "text": "Total",
                    "style": "tableHeader"
                }, {
                    "text": "Break",
                    "style": "tableHeader"
                }, {
                    "text": "Errors",
                    "style": "tableHeader"
                }],
                ["", " 2015-08-12, Wednesday", "", "", "", "", "0"],
            ]
        }
    }],
    "styles": {
        "tableStyle": {
            "margin": [30, 30, 30, 30]
        },
        "tableHeader": {
            "fontSize": 10,
            "bold": true,
            "italics": true,
            "color": "red"
        }
    },
    "defaultStyle": {
        "fontSize": 9
    }
}

And I get an error from PDF Make like this: image

Grid API Function

function exportGrid(format) {
            if (format == 'csv') {
                // var myElement = angular.element(document.querySelectorAll(".custom-csv-link-location"));
                $scope.gridApi.exporter.csvExport('all', 'all');
            } else if (format == 'pdf') {
                $scope.gridApi.exporter.pdfExport('all', 'all');
            }
        }

\ Note ** Ignore the CSV portion, I didn't begin working on that yet. Just the PDF part.

And when I try to debug for some reason the data is null by the time it get so the TextTools.prototype.buildInlines on line 15940 for the argument textArray. I'm still exploring and if needed I will create a plunkr but I just don't understand why this is working on the website and not in the app.

The data going into the grid is completely from the server, the grid columns, data and all. So it looks a bit something like this: image

This being said, could this be causing the issue? I've seen other exporter issues but none relating to the use case I'm listing above, unless I'm missing something in your guys' massive bug list. Sorry to add one more 😓

mikehuebner commented 9 years ago

Digging even more into I have this: image Which is called on line 14422 from PDFMake return this.styleStack.auto(node, function() {

and the "data from the thing" log is from line 14661 on this function DocMeasure.prototype.measureTable

Beginning to think this is a PDF make issue, but it could be me missing something extremely tiny. Just not seeing why it has data at one point and then doesn't have anything after that point. The textArray argument that it using from the node variable just null's out for some reason.

mikehuebner commented 9 years ago

Fixed it...

So the grid has a column with a null value because I want nothing to show. Which causes PDF Make to freak out DO NOT set a null displayName on the columns. With this in mind, I need to strip that column before it sends so I guess work on that begins. For anyone else that has this issue could come here as well to check it out.