遍历一个Angular.jsDatatableng-table中所有页面的所有记录

Iterate through all the records in all the pages in a Angular.js Datatable ng-table

我有一个 ng-table (angular.js datable) 实现,每页有 25 条记录,在页面上我有一个提交按钮,点击它我需要迭代遍历所有页面中的所有记录,查找本table.

中修改了哪些记录

下面是我的代码,我只能用它遍历当前选定页面中的记录,而不能遍历其余页面。

$scope.tableParams = new NgTableParams(
                    {
                        page: 1,
                        count: 25,
                    },
                    {
                        total: records.length,
                        getData: function ($defer, params) {
                            $scope.data = params.sorting() ? $filter('orderBy')(records, params.orderBy()) : result;
                            $scope.data = params.filter() ? $filter('filter')($scope.data, params.filter()) : $scope.data;
                            $scope.data = $scope.data.slice((params.page() - 1) * params.count(), params.page() * params.count());
                            $defer.resolve($scope.data);
                        }
                    });


var skus = [];
    angular.forEach($scope.tableParams.data, function (product) {
                    if (product.quantity > 0) {
                        var sku =
                          {
                            AddToCart: true,
                            CategoryId: product.categoryId,
                            PriceCharged: product.displayPrice,
                            Quantity: product.quantity,
                            SkuCode: product.skuCode
                         }
                        skus.push(sku);
                    }        
                });

也许您可以使用事件 ngTableEventsChannel.onDatasetChanged 来捕获修改的行并将其复制到新对象。 您也可以尝试在编辑的单元格上使用 ng-change。

请记住,您的所有记录都在记录对象中。