Extjs 更換主題

來源:互聯網
上載者:User

標籤:style   http   io   ar   os   使用   sp   for   on   

這裡基於 Extjs4.2(發文時官方剛發布了最新版5.0) 進行開發的,更換主題後,主題資訊儲存在本地 cookie 中,如果要儲存在資料庫中,請自行修改!

使用一個Combobox 讓使用者選擇皮膚!

{                            xtype: ‘combobox‘,                            itemId: ‘mycombobox1‘,                            padding: 0,                            fieldLabel: ‘皮膚更換            ‘,                            labelAlign: ‘right‘,                            labelPad: 1,                            labelWidth: 65,                            name: ‘theme‘,                            value: ‘ext-all.css‘,                            displayField: ‘name‘,                            forceSelection: true,                            queryMode: ‘local‘,                            store: ‘sys.Theme‘,                            typeAhead: true,                            valueField: ‘id‘,                            listeners: {                                change: { //改變選擇時觸發事件                                    fn: me.onMycomboboxChange11,                                    scope: me                                },                                afterrender: {//初始化資料                                    fn: me.onMycomboboxAfterRender11,                                    scope: me                                }                            }                        }
事件處理代碼如下: 採用 Ext.util.CSS.swapStyleSheet() 方法設定主題。

onMycomboboxChange11: function(field, newValue, oldValue, eOpts) {        if(newValue!=oldValue){            Ext.util.CSS.swapStyleSheet(‘theme‘, ‘../../extjs4.2/resources/css/‘+newValue);            var cp = new Ext.state.CookieProvider();            Ext.state.Manager.setProvider(cp);            cp.set("themes",newValue);        }    },    onMycomboboxAfterRender11: function(component, eOpts) {        var cp = new Ext.state.CookieProvider();        Ext.state.Manager.setProvider(cp);        //cp.set("themes",data.username);        var themes = cp.get("themes");        if(themes){            component.setValue(themes);            Ext.util.CSS.swapStyleSheet(‘theme‘, ‘../../extjs4.2/resources/css/‘+themes);        }    }
附上:

參考文章:

http://www.wenhaozhong.com/27.html


Extjs 更換主題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.