module 'ui.grid.autoResize'
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?
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.
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);
});
}
}; }]);
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.