angular-ui/ui-grid

UI Grid column auto width, two bugs are detected (with demo)

Open

#5,072 创建于 2016年2月6日

在 GitHub 查看
 (4 评论) (2 反应) (0 负责人)JavaScript (2,496 fork)batch import
good first issue

仓库指标

Star
 (5,395 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Please read the following post on stackoverflow:

jQuery(hiddenElement).width() is always zero when hiddenElement or its parent are hidden.

http://stackoverflow.com/questions/35246402/ui-grid-v0-3-1-column-auto-width-issue-detected/35246460#35246460

Here is an approach to fix it:

// Resize the grid on window resize events
          function gridResize($event) {
            grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm);
            grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm);
            console.log(grid.gridWidth);
            console.log(grid.gridHeight);
            if(!$($elm).is(':hidden') && grid.gridWidth > 0) { //add such if statement before                 
                grid.refreshCanvas(true); //this is UI Grid code
            }
          }

贡献者指南