ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

export functionality should be able to export sorted data

Open edenchen123 opened this issue 12 years ago • 7 comments

export functionality should be able to export sorted data

edenchen123 avatar Oct 30 '14 21:10 edenchen123

I think it does, if you export visible rows. The sorted rows are held in the visible rows cache. If you export all, then it uses grid.rows, which is not sorted. If you export visible, then it uses grid.visibleRows, which is sorted. I think this makes sense. If you haven't filtered, then visibleRows and allRows are the same thing, so you could just export visible rows. If you have filtered, then the sort would only apply to the filtered rows - we can't easily export sorted for rows that aren't visible.

PaulL1 avatar Oct 30 '14 21:10 PaulL1

Yes, but what about when data is paged? I have paged data and I would like to export all rows using the current sort. I have tried temporarily changing the page size to fit all rows, calling export on visible rows and then setting the page size back, however even with a notification to grid that the page size has changed, the exporter still exports just the current page.

csharpengineer avatar May 08 '15 15:05 csharpengineer

I believe there is now an option to get all paged data before export, it does require handling a callback.

PaulL1 avatar May 08 '15 19:05 PaulL1

Ah, thanks. Is this exporterAllDataPromise?

csharpengineer avatar May 08 '15 19:05 csharpengineer

Sounds right.

PaulL1 avatar May 08 '15 20:05 PaulL1

I'm using angular ui-grid for large set's of data, now i'm able to export the filtered result's from all paginations,when i apply the sort functionality along with it, it works on the view but not on the imported file, that is the user again needs to sort it after the download using excel(which isn't convenient).

NB: Extra dependencies i have used 1.xlsx.js 2.underscore.js 3.alasql.js

function exportData() {
            $scope.exportDatalist = _.filter($scope.gridApi.grid.rows, (o) => {
               return o.visible;
            });
            var entities = _.map($scope.exportDatalist, 'entity');
            alasql.promise('SELECT * INTO XLSX("Log_Details.xlsx",{headers:true}) FROM ?', [entities]);
        }

ruhaise avatar Nov 15 '17 12:11 ruhaise

@csharpengineer @PaulL1 Could you please show here the sample code, can be used to resolve this problem?

nisharamj avatar Oct 24 '18 14:10 nisharamj