angular-ui / ui-grid

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

expandable not showing subgrid details of last row #7092

Open Prox4 opened 4 years ago

Prox4 commented 4 years ago

I'm using expandable grid. If I scroll to the last row and expand the row ,subgrid data is not shown. It's blank, no data is visible. The same issue can be seen in the UI-grid official tutorial. http://ui-grid.info/docs/#!/tutorial/Tutorial:%20216%20Expandable%20grid

It works as expected when few records are present - like for 10 rows. Any workaround for this?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

galgalz commented 4 years ago

I found that the problem was with the variable: '!$scope.grid.isScrollingVertically' which is in the $scope.expandableRow.shouldRenderExpand function

So I just wrapped the condition and added: "|| $scope.row.isExpanded;"

I copied the directive below into a separate file into my project and so far it's working as intended.

angular.module('common').directive('uiGridRow',
        function () {
            return {
                priority: -200,
                scope: false,
                compile: function () {
                    return {
                        pre: function ($scope, $elm) {
                            if (!$scope.grid.options.enableExpandable) {
                                return;
                            }

                            $scope.expandableRow = {};

                            $scope.expandableRow.shouldRenderExpand = function () {
                                return ($scope.colContainer.name === 'body'&& $scope.grid.options.enableExpandable !== false && $scope.row.isExpanded && (!$scope.grid.isScrollingVertically || $scope.row.expandedRendered)) || $scope.row.isExpanded;
                            };

                            $scope.expandableRow.shouldRenderFiller = function () { 
                                return $scope.row.isExpanded && ( $scope.colContainer.name !== 'body' || ($scope.grid.isScrollingVertically && !$scope.row.expandedRendered));
                            };

                            if ($scope.grid.options.enableOnDblClickExpand) {
                                $elm.on('dblclick', function (event) {
                                    // if necessary, it is possible for everyone to stop the processing of a single click OR
                                    // Inside the Config in the output agent to enter a line:
                                    // event.stopPropagation()
                                    $scope.grid.api.expandable.toggleRowExpansion($scope.row.entity, event);
                                });
                            }
                        },
                        post: function ($scope, $elm, $attrs, controllers) { }
                    };
                }
            };
        });
mohdsaad17 commented 1 year ago

Hi @Prox4 does the issue still exists. I would like to work on it