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

module 'ui.grid.autoResize'

Open dardino opened this issue 11 years ago • 3 comments

Hi, i like so much the directive uiGridAutoResize but in some cases (ie: when i have more than one grid in a page) they have some performance problem due to timeout delay of 250 ms. I think making this time customizable can be a good idea. it is possible modifing the code like this:

// [...]
            else {
              startTimeout();
            }
          }, parseInt($attrs.uiGridAutoResize) || 250);
          //}, 250); // replaced with line above
        }
        startTimeout();
// [...]

after that we can use the directive in this way:

<div ui-grid="gridOptions" ui-grid-auto-resize="1000"></div>

what about this idea?

dardino avatar Apr 02 '15 11:04 dardino

We would normally do this with a gridOption rather than a directive parameter, although both would work. Adding a configurable parameter to this would be something I think we'd accept as a PR.

PaulL1 avatar Apr 02 '15 18:04 PaulL1

Do you think that it's better to change it to event drive? see below:

vipWidgets.directive('vpGridAutoResize', ['$timeout', 'gridUtil', function ($timeout, gridUtil) { return { require: 'uiGrid', scope: false, link: function ($scope, $elm, $attrs, uiGridCtrl) { var prevGridWidth, prevGridHeight, debounce;

    function getDimensions() {
        prevGridHeight = gridUtil.elementHeight($elm);
        prevGridWidth = gridUtil.elementWidth($elm);
    }

    // Initialize the dimensions
    getDimensions();
    $scope.$watch(function() { return $($elm).height(); },function(){
        $timeout.cancel(debounce);
        debounce = $timeout(function(){
            var newGridHeight = gridUtil.elementHeight($elm);
            var newGridWidth = gridUtil.elementWidth($elm);

            if (newGridHeight !== prevGridHeight || newGridWidth !== prevGridWidth) {
                uiGridCtrl.grid.gridHeight = newGridHeight;
                uiGridCtrl.grid.gridWidth = newGridWidth;

                $scope.$apply(function () {
                    uiGridCtrl.grid.refresh()
                        .then(function () {
                            getDimensions();
                        });
                });
            }
        },200);
    });
}

}; }]);

edenchen123 avatar May 26 '15 03:05 edenchen123

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.

stale[bot] avatar May 23 '18 06:05 stale[bot]