Closed mathanpec closed 9 years ago
For the time being, no. I believe it could be solved through angular events. Will think about it.
I have done it using alias in ng-repeat (variable in expression as alias_expression ) by modifying trNgGrid code . Will raise a pull request for that.
@mathanpec can you give more information on how you achieved this? it's a critical feature to my application to export the filtered data to csv and also pass it to another view for a printable report.
@jdforsythe , In the current version of trNgGrid, currentDisplayItems are being computed as filteredItems. But they aren't just exposed to external scope. So you need to modify the code little bit to get it via external scope same like how you selectedItems is exposed.
@MoonStorm, I see that filteredItems is being computed internally. But they aren't exposed like selectedItem. Is there any specific reason for not exposing this ? Because I had modified the code little bit to expose this also as isolated scope and wanted to know whether it is right approach?
@mathanpec Not a bad solution. The only concern I've got is that being exposed this way it allows for external logic to make changes to the list of displayed items. For the selected items it makes sense to have it that way.
@mathanpec Actually, there is an additional concern. The filtered items you were mentioning are actually already formatted, have the field names mangled, plus they hold a "very well hidden" data item. They were not meant to be exposed.
The selected items are actual data items.
The change I made was
648d647
< scope.$emit('exportableItemsChanged', scope.filteredItems);
then in the controller:
$scope.$on('exportableItemsChanged', function(event, data) {
$scope.exportableItems = angular.forEach(data, function(value) {
this.push(value.$$_gridItem);
});
});
That is very well hidden data item, I presume. It's useful, though because I run the original object through a parser and pass it to alasql.js and xlsx.js to export the filtered and ordered data as Excel and CSV files.
As for the OP question, it doesn't respect pagination.
Found some time to think about it and decided to implement it via data binding, as @mathanpec suggested, but instead of exposing the displayed items, it'll provide the data items instead.
Please see the updated Grid Options section on the demo site for more details. The changes were pushed on the master branch.
Say when we give 100 objects to the grid and the current page size is 5, Is there any provision to know those 5 objects? Same with filtering also, Is there any way to get the objects which is being displayed as result of filtering or sorting? I couldn't find anything in the documentation.