After scrolling down > hide > show via ng-show toggle makes rows disappear until triggering scroll again
I have a grid that has an ng-show directive on it. The grid loads fine and if I don't scroll, I can toggle the ng-show to hide the grid and show it again and everything works fine. But if I scroll down the grid and select a row, then toggle the visibility via ng-show, the rows disappear until I trigger scrolling via mouse wheel. I have tried:
- saving state and restoring it
- scrollTo selected entity
- refreshing grid
- calling notifyDataChanged
And all have failed to make the grid behave appropriately in showing the last "viewport" that was there before toggling ng-show.
My grid options are as follows:
appScopeProvider: this, flatEntityAccess: true, minRowsToShow: 5, rowHeight: 27, enableColumnMenus: false, enableRowSelection: true, enableFullRowSelection: true, modifierKeysToMultiSelect: true, enableSelectAll: false, enableSelectionBatchEvent: false, selectionRowHeaderWidth: 35, showGridFooter: true, enableColumnResizing: true, enableFiltering: false, infiniteScrollRowsFromEnd: 40, infiniteScrollUp: false, infiniteScrollDown: true, enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER, enableVerticalScrollbar: uiGridConstants.scrollbars.ALWAYS
I also have onRegisterApi declared as follows: onRegisterApi: function(gridApi) { vm.vmGridApi = gridApi; gridApi.selection.on.rowSelectionChanged(null, function (row) { vm.onGridsSelectionChanged(); }); gridApi.grid.registerRowsProcessor(vm.filterCurrentGrid); gridApi.infiniteScroll.on.needLoadMoreData(null, vm.fetchNextPageOfData); },
- Row selection changed method just gets selected entity and sets it in variable on controller.
- Register row processor uses single text input to filter rows (as per tutorial, no variation)
- Need Load more data fetches next page of data for infinite scroll (as per tutorial, no variation)
Thank you in advance to all for assisting with this issue.
ng-show and ui-grid are not friends. use ng-if and put the grid into the correct state after it renders
Thanks for that tip. I tried using the ui.grid.saveState module but I keep running into issues with it restoring state on my grid. The most important thing I need is just getting the scroll position back. When you say "after it renders", what event do you recommend using? gridApi.core.on.rowsRendered fires multiple times and has caused some issues with the state restore.
Exactly same problem here. tried the approach suggested with ng-if however the scroll up will move to the top. saveState.restore not helpful on this.
Any progress / new advice on this?
Thanks for contributing! This repository has been transferred, and we're preparing the new 5.x release. We're closing older issues and pull requests as part of the reset. Please join us on Discord to follow the work or continue the conversation: https://discord.gg/Baz4w8ZWN