PDA

View Full Version : Dynamic grid column setting



hcallesis
27 May 2020, 11:03 AM
I'm using Sencha Architect 4.2.8 and ExtJS framework 7.2.0. I have a stateful grid where the intent is the user will be able to select groups of columns and give them a name, so the group can be selected from a dropdown, The groups would be a subset of all the grid columns, and would be the only ones to show (unselected columns would be hidden). I have everything almost working - I use getState() to get the column config, the grid groups are saved to the user's settings in a DB, they get read back properly and work (to a point) with applyState(). it's the "to a point" that's the issue.
If I hook the staterestore event, I can set the grid to the last config used (which is saved by name) when it initially loads. I can see applyState trying to work when I select a group name from the dropdown, the issue is if the group being selected has more columns than the one currently being used, those extra columns don't show up correctly. The header bar makes room for them, but the headers don't appear and the columns aren't selectable. Only columns that are shared with the previous state are displayed, in the positions they would be in in the new state, but they're all that can be seen or interacted with.
I've tried grid.updateLayout(), grid.getView().refresh(); I've tried the suspend layout/loop and toggle hidden/resume layout trick; nothing fixes the grid. I've managed to work around a different applyState glitch/side-effect but this one has me stymied. Any suggestions are greatly appreciated.