问题
I am giving some items (containers), in "View", a layout of hbox
. Now I want to give flex
value to each item through the "Controller". How can I do this?
I have gone through the docs but can't find any method like setFlex
.
EDIT :
Ext.apply(Ext.getCmp('IdHere'), {flex: 1});
I have got the answer from this link. But now the problem is that even I am changing the flex values dynamically, the view of the containers is not changing. It is remaining same.
I am not assigning flex values initially in "View" as stated here
回答1:
My first guess would be that need to rerun the layout process by calling doLayout()
I am not quite sure but I think you have to call in on the parent element which holds the hbox
layout.
回答2:
Get your parent container (on which you have applied layout hbox or vbox) then get items and finally change the flex and update the layout
var ct = me.up('#parentComponent');
ct.items.get('itemId1').flex = 2;
ct.items.get('itemId2').flex = 2;
ct.updateLayout();
来源:https://stackoverflow.com/questions/15381200/add-flex-value-dynamically-to-controller-in-extjs