[ExtJS5学习笔记]sencha ext js 5.1.0中动态更换皮肤主题

本文地址:http://blog.csdn.net/sushengmiyan/article/details/42016107

本文作者:sushengmiyan

------------------------------------------------------------------------------------------------------------------------------------

为方便起见,使用sencha cmd创建一个工程,使用app build命令build工程,使用web start命令启动服务。

好了,现在更改下main.js中的一点代码,增加如下内容到panel中:

,{
        xtype: ‘combo‘,
        width: ‘100‘,
		labelWidth: ‘40‘,
		fieldLabel: ‘Theme‘,
		displayField: ‘name‘,
		valueField: ‘value‘,
		//labelStyle: ‘cursor:move;‘,
		//margin: ‘5 5 5 5‘,
		queryMode: ‘local‘,
		store: Ext.create(‘Ext.data.Store‘, {
			fields: [‘value‘, ‘name‘],
			data : [
				{ value: ‘neptune‘, name: ‘Neptune主题‘ },
				{ value: ‘neptune-touch‘, name: ‘Neptune Touch主题‘ },
				{ value: ‘crisp‘, name: ‘Crisp主题‘ },
				{ value: ‘crisp-touch‘, name: ‘Crisp Touch主题‘ },
				{ value: ‘classic‘, name: ‘Classic主题‘ },
				{ value: ‘gray‘, name: ‘Gray主题‘ }
			]
		}),
		//value: theme,
		listeners: {
			select: function(combo) {
				var  theme = combo.getValue();
				var	href = ‘ext/packages/ext-theme-‘+theme+‘/build/resources/ext-theme-‘+theme+‘-all.css‘;
				var	link = Ext.fly(‘theme‘);

				if(!link) {
					link = Ext.getHead().appendChild({
						 tag:‘link‘,
						 id:‘theme‘,
						 rel:‘stylesheet‘,
						 href:‘‘
					});
				};
				link.set({href:Ext.String.format(href, theme)});
			}
		}
    }

main.js代码应该如下所示:(完整内容)

/**
 * This class is the main view for the application. It is specified in app.js as the
 * "autoCreateViewport" property. That setting automatically applies the "viewport"
 * plugin to promote that instance of this class to the body element.
 *
 * TODO - Replace this content of this view to suite the needs of your application.
 */
Ext.define(‘oaSystem.view.main.Main‘, {
    extend: ‘Ext.container.Container‘,
    requires: [
        ‘oaSystem.view.main.MainController‘,
        ‘oaSystem.view.main.MainModel‘
    ],

    xtype: ‘app-main‘,

    controller: ‘main‘,
    viewModel: {
        type: ‘main‘
    },

    layout: {
        type: ‘border‘
    },

    items: [{
        xtype: ‘panel‘,
        bind: {
            title: ‘{name}‘
        },
        region: ‘west‘,
        html: ‘<ul><li>This area is commonly used for navigation, for example, using a "tree" component.</li></ul>‘,
        width: 250,
        split: true,
        tbar: [{
            text: ‘Button‘,
            handler: ‘onClickButton‘
        },{
        xtype: ‘combo‘,
        width: ‘100‘,
		labelWidth: ‘40‘,
		fieldLabel: ‘Theme‘,
		displayField: ‘name‘,
		valueField: ‘value‘,
		//labelStyle: ‘cursor:move;‘,
		//margin: ‘5 5 5 5‘,
		queryMode: ‘local‘,
		store: Ext.create(‘Ext.data.Store‘, {
			fields: [‘value‘, ‘name‘],
			data : [
				{ value: ‘neptune‘, name: ‘Neptune主题‘ },
				{ value: ‘neptune-touch‘, name: ‘Neptune Touch主题‘ },
				{ value: ‘crisp‘, name: ‘Crisp主题‘ },
				{ value: ‘crisp-touch‘, name: ‘Crisp Touch主题‘ },
				{ value: ‘classic‘, name: ‘Classic主题‘ },
				{ value: ‘gray‘, name: ‘Gray主题‘ }
			]
		}),
		//value: theme,
		listeners: {
			select: function(combo) {
				var  theme = combo.getValue();
				var	href = ‘ext/packages/ext-theme-‘+theme+‘/build/resources/ext-theme-‘+theme+‘-all.css‘;
				var	link = Ext.fly(‘theme‘);

				if(!link) {
					link = Ext.getHead().appendChild({
						 tag:‘link‘,
						 id:‘theme‘,
						 rel:‘stylesheet‘,
						 href:‘‘
					});
				};
				link.set({href:Ext.String.format(href, theme)});
			}
		}
    }]
    },{
        region: ‘center‘,
        xtype: ‘tabpanel‘,
        items:[{
            title: ‘Tab 1‘,
            html: ‘<h2>Content appropriate for the current navigation.</h2>‘
        }]
    }]
});

纠结了很久的问题终于释怀了。之前看的都是使用swapstylesheet我一直么有成功过。偶尔看的了这篇文章,觉得不错,果真成功了。

http://extjs.eu/lightweight-theming/

推荐一下,这个网站,内容比较充实,界面也比较好看。就是有些插件需要花钱购买。

时间: 2024-07-30 08:11:45

[ExtJS5学习笔记]sencha ext js 5.1.0中动态更换皮肤主题的相关文章

[ExtJS5学习笔记]第二十九节 sencha ext js 5.1.0中动态更换皮肤主题

本文地址:http://blog.csdn.net/sushengmiyan/article/details/42016107 本文作者:sushengmiyan ------------------------------------------------------------------------------------------------------------------------------------ 为方便起见,使用sencha cmd创建一个工程,使用app buil

[ExtJS5学习笔记]第二十八节 sencha ext js 5.1.0发布版本正式发布

本文地址:http://blog.csdn.net/sushengmiyan/article/details/41242993 本文作者:sushengmiyan ------------------------------------------------------------------------------------------------------------------------------------ 官方博客发布了这个新版本说明,英文文章请戳下面 http://www.

[学习笔记] Sencha Cmd 学习笔记 Sencha Cmd是什么

本文地址: http://blog.csdn.net/sushengmiyan/article/details/38295575 本文作者:sushengmiyan -------------------------------------------------------------资源链接----------------------------------------------------------------------- 翻译来源  Sencha Cmd官方网站: http://w

[ExtJS5学习笔记]第十六节 Extjs5使用panel新增的ViewModel属性绑定数据

本文地址:http://blog.csdn.net/sushengmiyan/article/details/39078627 sencha官方API:http://docs.sencha.com/extjs/5.0/apidocs/#!/api/Ext.panel.Panel-cfg-viewModel 本文作者:sushengmiyan ------------------------------------------------------------------------------

sencha ext js 6 入门

Sencha Ext JS号称是目前世界上最先进和最强大的.支持多平台多设备的JavaScript应用程序开发框架.首先看一下Ext JS的发展简史. 1 Ext JS发展简史 YUI-Ext的作者Jack Slocum(杰克.斯洛克姆)打算对基于BSD协议的Yahoo User Interface (YUI)库进行自定义的扩展,但后来一度风头盖过其父辈YUI: 在2006年底,YUI-Ext被简化为Ext,反映了它作为一个框架的成熟和独立.该公司成立于2007年初,Ext现在为双执照,使用LG

【翻译】在Ext JS 5应用程序中如何使用路由

原文:How to Use Routing in Your Ext JS 5 Apps 简介 Ext JS 5是一个重要的发布版本,它提供了许多新特性来创建丰富的.企业级的Web应用程序.MVVM和双向数据绑定为开发人员承担了大量的繁重工作.在Ext JS 5种,另一个新特性就是路由,它可以在控制器内轻松的管理历史记录.前进和后退按钮是每个浏览器都会拥有的公共用户接口,现在,使用Ext JS 5在单页面应用程序中处理导航变得相当简单了. Ext JS 5路由 在Ext JS,已经可以使用Ext.

angular学习笔记(二十八-附1)-$resource中的资源的方法

通过$resource获取到的资源,或者是通过$resource实例化的资源,资源本身就拥有了一些方法,比如$save,可以直接调用来保存该资源: 比如有一个$resource创建的服务: var service = angular.module('myRecipe.service',['ngResource']); service.factory('Recipe',['$resource',function($resource){ return $resource('/recipe/:id',

struts2学习笔记(三)—— 在用户注册程序中使用验证框架

实现目标: 1.使用验证框架对用户注册信息进行验证 2.验证用户名.密码.邮箱不能为空 3.验证用户名.密码长度 4.验证邮件地址格式 具体实现 一.Struts2应用的基础配置 这里不做详细阐述,具体为web.xml.相关jar包的配置 二.将页面显示的文本内容放到资源文件中 1.查看用户注册程序中的所有页面,找到所有可以显示的文本内容,将它们分离出来放到资源文件中. 2.与相关的Action类同名,以.preperties为扩展名,与Action类位于同一个包中,只能由该Action访问 R

VSTO学习笔记(四)从SharePoint 2010中下载文件

原文:VSTO学习笔记(四)从SharePoint 2010中下载文件 上一次我们开发了一个简单的64位COM加载项,虽然功能很简单,但是包括了开发一个64位COM加载项的大部分过程.本次我们来给COM加载项添加一些功能:从SharePoint 2010的文档库中下载一个Excel文档到本地. 示例代码下载 本系列所有示例代码均在 Visual Studio 2010 Ultimate RC + Office 2010 Professional Plus Beta x64 上测试通过. 1.首先