核心代碼就一句話:
[javascript] Ext.util.CSS.swapStyleSheet('window', 'JSLib/ext/resource/css/'+combo.getValue()+'.css');
Ext.util.CSS.swapStyleSheet('window', 'JSLib/ext/resource/css/'+combo.getValue()+'.css');
下面使用下拉菜單更換主題:
[javascript] {
xtype: 'combo',
store: new Ext.data.SimpleStore({
fields: ['id', 'theme-view','theme-value'],
data: JpkFrame.data.themes
}),
width: 80,
editable: false,
displayField: 'theme-view',
name: 'change_theme',
editable:false,
//typeAhead: true,
value:'默認風格',
mode: 'local',
valueField:'theme-value',
triggerAction: 'all',
selectOnFocus: true,
listeners: {
select: function(combo, record, index){
Ext.util.CSS.swapStyleSheet('window', 'JSLib/ext/resources/css/'+combo.getValue()+'.css');
}
}
}
JpkFrame.data.themes=[
[0,'默認風格','ext-all'],
[1,'深藍風格','xtheme-slate'],
[2,'黑色風格','xtheme-black'],
[3,'銀白風格','xtheme-gray'],
[4,'綠色風格','xtheme-olive'],
[5,'灰色風格','xtheme-darkgray'],
[6,'紫色風格','xtheme-purple']
]
摘自 果凍村長