angular-ui / ui-grid

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

Dynamically toggle between gridOptions #6838

Open asdf1143 opened 6 years ago

asdf1143 commented 6 years ago

I am in much need of help to dynamically change the gridOptions particularly the styles, as the column definitions do change. Here is a plnkr showing my attempt.

http://plnkr.co/edit/bH9TWQwJ0on6B8JLu3EX?p=preview

The column definitions change according to the currently set gridoptions but styles like rowHeight and showHeader do not change.

getLargeRowHeightGridOptions has rowHeight of 50 and showHeader as false, getSmallRow... has rowHeight of 15 and should show header. However, when you click "Toggle GridOptions" the only thing that changes are the column definitions.

You can see in my plnkr in the method "toggleGridOptions" I am trying to use vm.gridApi.core.refresh(). I also tried using vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS); and vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL)

None of these worked, do you have any suggestions on say, in my plnkr how to really toggle between gridoptions? How to refresh gridApi properly so that the all the gridoptions get toggled not just the columns? Thanks!

I have tried to look up terms like "refresh gridoptions dynamically" in these links. https://github.com/angular-ui/ui-grid/issues/5242 https://stackoverflow.com/questions/26634063/how-to-use-refresh-method-in-ui-grid https://stackoverflow.com/questions/34666859/ui-grid-does-not-refresh-the-dynamic-style-after-modify-the-modal-data

pakornsak commented 6 years ago

Unfortunately, here are the options that will be refreshed by uiGridConstants.dataChange.OPTIONS.

grid.footerHeight grid.columnFooterHeight grid.options.isRowSelectable grid.options.enableRowSelection grid.options.enableFullRowSelection

(ui-grid v4.6.3)