[英]How to change the extraParams config of a proxy at runtime in extjs?
[英]How do I change config options (minWidth) on the fly in ExtJS 4.0.5?
我有一個Ext.window.Window組件,在配置選項中設置了minHeight和minWidth,如下所示:
config: {
minWidth: 860,
minHeight: 580
},
現在,我想在像這樣的函數中更改這些屬性:
Ext.getCmp('x').setMinWidth(1280);
但是Extender 4.0.5中尚不存在該Setter。 (在更高版本中會)
我也嘗試這樣做:
Ext.getCmp('x').config.minWidth = 1280;
但它也不起作用。
提前致謝。
在ExtJS 窗口中 ,可以在更改配置值后使用
updateLayout
方法。
updateLayout更新此組件的布局。 如果此更新影響了此組件ownerCt,則將調用該組件的updateLayout方法來執行布局。 否則,將僅布局此組件(及其子項)。
在這里,我創建了sencha小提琴演示。 它將顯示工作方式,希望這將幫助您解決問題或達到您的要求。
Ext.create('Ext.window.Window', {
title: 'Hello',
minWidth: 400,
minHeight: 300,
layout: 'vbox',
items: [{ // Let's put an empty grid in just to illustrate fit layout
xtype: 'grid',
flex: 1,
width: '100%',
border: false,
store: {
fields: ['name', 'email', 'phone'],
data: {
'items': [{
'name': 'Lisa',
"email": "lisa@simpsons.com",
"phone": "555-111-1224"
}, {
'name': 'Bart',
"email": "bart@simpsons.com",
"phone": "555-222-1234"
}, {
'name': 'Homer',
"email": "home@simpsons.com",
"phone": "555-222-1244"
}, {
'name': 'Marge',
"email": "marge@simpsons.com",
"phone": "555-222-1254"
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
},
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Phone',
dataIndex: 'phone'
}],
}, {
xtype:'button',
text: 'Update min height and width with Random Number',
height: 40,
margin: 10,
width:'100%',
renderTo: Ext.getBody(),
handler: function () {
/**
* Returns a random integer between min (inclusive) and max (inclusive)
* Using Math.round() will give you a non-uniform distribution!
*/
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var num = getRandomInt(300, 600),
wind = this.up('window');
wind.minHeight = num;
wind.minWidth = num;
wind.updateLayout();
}
}]
}).show();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.