Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export in IE11 doesn't work #1116

Closed
MLauri opened this issue Jun 9, 2016 · 1 comment
Closed

Export in IE11 doesn't work #1116

MLauri opened this issue Jun 9, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@MLauri
Copy link

MLauri commented Jun 9, 2016

This issue affects also the demo app (http://marmelab.com/ng-admin-demo/index.html)

IE Version: 11.0.9600

Export failed with the error: 'The data area passed to a system call is too small.'

@MLauri
Copy link
Author

MLauri commented Sep 16, 2016

I solved this issue redefining the function exportToCsv (note the if statement):

            scope.exportToCsv = function () {
                var rawEntries;
                exportView.perPage(1000000);
                ReadQueries.getAll(exportView, undefined, $stateParams.search, $stateParams.sortField, $stateParams.sortDir)
                    .then(response => {
                        rawEntries = response.data;
                        return rawEntries;
                    })
                    .then(rawEntries => ReadQueries.getReferenceData(exportView.fields(), rawEntries))
                    .then(referenceData => {
                        const references = exportView.getReferences();
                        for (var name in referenceData) {
                            AdminDescription.getEntryConstructor().createArrayFromRest(
                                referenceData[name],
                                [references[name].targetField()],
                                references[name].targetEntity().name(),
                                references[name].targetEntity().identifier().name()
                            ).map(entry => scope.datastore.addEntry(references[name].targetEntity().uniqueId + '_values', entry));
                        }
                    })
                    .then(function () {
                        var entries = exportView.mapEntries(rawEntries);

                        // shortcut to diplay collection of entry with included referenced values
                        scope.datastore.fillReferencesValuesFromCollection(entries, exportView.getReferences(), true);

                        var results = [];

                        for (var i = entries.length - 1; i >= 0; i--) {
                            results[i] = formatEntry(entries[i]);
                            //patch per dati numerici...migliorare!
                            if(results[i].hasOwnProperty('Amount')){
                                results[i].Amount=entries[i].values.amount.replace('.', ',');
                            }
                            if(results[i].hasOwnProperty('Rate')){
                                results[i].Rate=entries[i].values.load_change.replace('.', ',');
                            }
                        }
                        var list_export_options = listView.exportOptions();
                        var basic_options = {
                                              quotes: false,
                                              delimiter: ";",
                                              newline: "\r\n"
                                            };
                        var csv = Papa.unparse(results, angular.extend({}, 
                                                                       list_export_options, 
                                                                       basic_options));

                        if(window.navigator.msSaveOrOpenBlob) {
                            var blob = new Blob([csv], {type: 'text/csv'});
                            window.navigator.msSaveOrOpenBlob(blob, scope.entity.name() + '.csv');
                        } else {
                            var fakeLink = document.createElement('a');
                            document.body.appendChild(fakeLink);
                            fakeLink.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(csv));
                            fakeLink.setAttribute('download', scope.entity.name() + '.csv');
                            fakeLink.click();
                        }
                    }, function (error) {
                        notification.log(error.message, {addnCls: 'humane-flatty-error'});
                    });
            };

@Phocea Phocea added bug and removed Hacktober Fest labels Nov 18, 2016
@Phocea Phocea added this to the 1.0 milestone Nov 18, 2016
Kmaschta added a commit that referenced this issue Dec 22, 2016
@Kmaschta Kmaschta self-assigned this Dec 22, 2016
Kmaschta added a commit that referenced this issue Dec 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants