Is there a way to effectively undo an "auto fit all columns" and resize a ListGrid to fit in the visible space ? On initial draw all columns are sized appropriately to fit in the available space - but may be squished or clipped to fit. Auto Fit All Columns introduces a scroll bar and some of my fields are no longer visible - but no columns are clipped. How do I get back to the original state so I can see all fields - even if they're clipped?
Announcement
Collapse
No announcement yet.
X
-
Actually resetting field state should not remove fields that are currently present in the grid but were not present when the field state was saved so this shouldn't be a problem for you.
You may want to try this out and see if it "just works" for you.
If not, you could work around it at the application level by looking at the set of fields in the grid before 'setFieldState' is applied, then re-adding any that have been removed (or showing ones that have been hidden).
Comment
-
This didn't quite work for me - I suspect because my application is setting the view state with setViewState before the component has been drawn - so getFieldState doesn't always give the correct state. I was able to use this code, however, to achieve the results I want:
Code:List fieldState = new ArrayList(); for (ListGridField f : getFields()) { Map<String, Object> state = new HashMap<String, Object>(); state.put("name", f.getName()); state.put("width", "*"); state.put("autoFitWidth", false); fieldState.add(state); } setFieldState(JSON.encode(JSOHelper.convertToJavaScriptArray(fieldState.toArray())));
Comment
Comment