`
erichua
  • 浏览: 514328 次
  • 性别: Icon_minigender_2
  • 来自: 远方
社区版块
存档分类
最新评论

Extjs学习总结---checkbox的focus解决

阅读更多
Extjs中的checkbox无法获得焦点。通过重载可以解决这个问题。
Ext.override(Ext.form.Checkbox, {
			onRender : function(ct, position) {
				Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
				if (this.inputValue !== undefined) {
					this.el.dom.value = this.inputValue;
				}
				// this.el.addClass('x-hidden');
				this.innerWrap = this.el.wrap({
					// tabIndex: this.tabIndex,
					cls : this.baseCls + '-wrap-inner'
				});
				this.wrap = this.innerWrap.wrap({
					cls : this.baseCls + '-wrap'
				});
				this.imageEl = this.innerWrap.createChild({
					tag : 'img',
					src : Ext.BLANK_IMAGE_URL,
					cls : this.baseCls
				});
				if (this.boxLabel) {
					this.labelEl = this.innerWrap.createChild({
						tag : 'label',
						htmlFor : this.el.id,
						cls : 'x-form-cb-label',
						html : this.boxLabel
					});
				}
				// this.imageEl = this.innerWrap.createChild({
				// tag: 'img',
				// src: Ext.BLANK_IMAGE_URL,
				// cls: this.baseCls
				// }, this.el);
				if (this.checked) {
					this.setValue(true);
				} else {
					this.checked = this.el.dom.checked;
				}
				this.originalValue = this.checked;
			},
			afterRender : function() {
				Ext.form.Checkbox.superclass.afterRender.call(this);
				// this.wrap[this.checked ? 'addClass' :
				// 'removeClass'](this.checkedCls);
				this.imageEl[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
			},
			initCheckEvents : function() {
				// this.innerWrap.removeAllListeners();
				this.innerWrap.addClassOnOver(this.overCls);
				this.innerWrap.addClassOnClick(this.mouseDownCls);
				this.innerWrap.on('click', this.onClick, this);
				// this.innerWrap.on('keyup', this.onKeyUp, this);
			},
			onFocus : function(e) {
				Ext.form.Checkbox.superclass.onFocus.call(this, e);
				// this.el.addClass(this.focusCls);
				this.innerWrap.addClass(this.focusCls);
			},
			onBlur : function(e) {
				Ext.form.Checkbox.superclass.onBlur.call(this, e);
				// this.el.removeClass(this.focusCls);
				this.innerWrap.removeClass(this.focusCls);
			},
			onClick : function(e) {
				if (e.getTarget().htmlFor != this.el.dom.id) {
					if (e.getTarget() !== this.el.dom) {
						this.el.focus();
					}
					if (!this.disabled && !this.readOnly) {
						this.toggleValue();
					}
				}
				// e.stopEvent();
			},
			onEnable : Ext.form.Checkbox.superclass.onEnable,
			onDisable : Ext.form.Checkbox.superclass.onDisable,
			onKeyUp : undefined,
			setValue : function(v) {
				var checked = this.checked;
				this.checked = (v === true || v === 'true' || v == '1' || String(v)
						.toLowerCase() == 'on');
				if (this.rendered) {
					this.el.dom.checked = this.checked;
					this.el.dom.defaultChecked = this.checked;
					// this.wrap[this.checked ? 'addClass' :
					// 'removeClass'](this.checkedCls);
					this.imageEl[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
				}
				if (checked != this.checked) {
					this.fireEvent("check", this, this.checked);
					if (this.handler) {
						this.handler.call(this.scope || this, this,
								this.checked);
					}
				}
			},
			getResizeEl : function() {
				// if(!this.resizeEl){
				// this.resizeEl = Ext.isSafari ? this.wrap :
				// (this.wrap.up('.x-form-element', 5) || this.wrap);
				// }
				// return this.resizeEl;
				return this.wrap;
			}
		});
		Ext.override(Ext.form.Radio, {
					checkedCls : 'x-form-radio-checked'
				});


css
		<style type="text/css">
.x-form-check-group .x-form-check-wrap,.x-form-radio-group .x-form-radio-wrap
	{
	height: auto;
}

.ext-ie .x-form-check-group .x-form-check-wrap,.ext-ie .x-form-radio-group .x-form-radio-wrap
	{
	height: auto;
}

.x-form-check-wrap,.x-form-radio-wrap {
	padding: 1px 0 3px;
	line-height: 18px;
}

.ext-ie .x-form-check-wrap,.ext-ie .x-form-radio-wrap {
	padding-top: 3px;
}

.ext-strict .ext-ie7 .x-form-check-wrap,.ext-strict .ext-ie7 .x-form-radio-wrap
	{
	padding-bottom: 1px;
}

.x-form-check-wrap-inner,.x-form-radio-wrap-inner {
	display: inline;
	padding: 0;
}

.x-form-check,.x-form-radio {
	height: 13px;
	width: 13px;
	vertical-align: bottom;
	margin: 2px 0;
}

.ext-ie .x-form-check,.ext-ie .x-form-radio {
	margin-top: 1px;
}

.ext-strict .ext-ie7 .x-form-check,.ext-strict .ext-ie7 .x-form-radio {
	margin-bottom: 4px;
}

.ext-opera .x-form-check,.ext-opera .x-form-radio {
	margin-top: 3px;
}

.x-form-check-focus .x-form-check,.x-form-check-over .x-form-check,.x-form-check-focus .x-form-radio,.x-form-check-over .x-form-radio
	{
	background-position: -13px 0;
}

.x-form-check-down .x-form-check,.x-form-check-down .x-form-radio {
	background-position: -26px 0;
}

.x-item-disabled .x-form-check,.x-item-disabled .x-form-radio {
	background-position: -39px 0;
}

.x-form-check-checked,.x-form-radio-checked {
	background-position: 0 -13px;
}

.x-form-check-focus .x-form-check-checked,.x-form-check-over .x-form-check-checked,.x-form-check-focus .x-form-radio-checked,.x-form-check-over .x-form-radio-checked
	{
	background-position: -13px -13px;
}

.x-form-check-down .x-form-check-checked,.x-form-check-down .x-form-radio-checked
	{
	background-position: -26px -13px;
}

.x-item-disabled .x-form-check-checked,.x-item-disabled .x-form-radio-checked
	{
	background-position: -39px -13px;
}

.x-form-check-wrap-inner input,.x-form-radio-wrap-inner input {
	position: absolute;
	-ms-filter: "alpha(opacity=0)";
	filter: alpha(opacity = 0);
	-moz-opacity: 0;
	opacity: 0;
}
</style>
4
0
分享到:
评论

相关推荐

    语言程序设计资料:ExtJs学习笔记-2积分.doc

    语言程序设计资料:ExtJs学习笔记-2积分.doc

    ExtJs常用布局--layout详解实例代码

    ExtJs常用布局--layout详解实例代码: ExtJs常见的布局方式有:border、form、absolute、column、accordion、table、fit、card、anchor 另外,不常见的布局有:tab、vbox、hbox 具体使用方法可见该文件的案例代码。 ...

    extjs-620-docs.zip

    extjs-620-docs官方文档extjs-620-docs官方文档extjs-620-docs官方文档

    extjs-theme-bootstrap

    "extjs-theme-bootstrap" 是针对 EXTJS4 的一个主题,它借鉴了 Bootstrap 的设计风格,让 EXTJS4 应用程序具有更加现代化和一致的外观。 Bootstrap 是一个流行的前端开发框架,由 Twitter 推出,主要用于构建响应式...

    ExtJS快速入门--传智播客--蔡世友

    ExtJS快速入门--传智播客--蔡世友

    extJs-5.0.1-gpl(part1)

    extJs-5.0.1-gpl附带sencha cmd安装程序、ruby编译包(分为32位和64位)和教程,一共四部分

    extjs2----关于extjs 的使用,操作

    描述中提到内容较为初级,适合初学者学习,这表明我们将探讨的是ExtJS的基础概念和常用组件。 首先,让我们来了解一下ExtJS的核心概念。ExtJS基于组件模型,允许开发者构建复杂的用户界面,这些组件可以是按钮、...

    extjs-theme-bootstrap-master.zip

    "extjs-theme-bootstrap-master.zip" 文件很可能是ExtJS的一个主题包,它集成了Bootstrap的样式,使得ExtJS组件能够呈现出Bootstrap的经典外观。 在深入讲解这个主题之前,让我们先了解一下基础概念: 1. **ExtJS*...

    解决 extjs2.2 给tree-panel 添加 checkbox 的add-on

    标题提到的“解决extjs2.2给tree-panel添加checkbox的add-on”正是为了解决这个问题,提供了一个扩展插件,使得用户可以在Tree Panel的节点上添加复选框。 这个扩展插件包含了以下几个关键文件: 1. **...

    extjs-620-docs.rar完全离线版

    此"extjs-620-docs.rar"压缩包包含了该版本的完全离线版API文档,旨在解决在没有网络连接或网络环境不稳定时,开发者仍然可以便捷地查阅和学习ExtJS 6.2.0的相关知识。 API 文档是任何开发者的重要工具,特别是对于...

    extjs-OA extjs-oa

    一个extjs的OA项目 extjs-OA extjs-oaextjs-OA extjs-oa

    ExtJS-4.2.2-gpl.rar

    总结,"ExtJS-4.2.2-gpl.rar"是一个全面的学习和开发资源,涵盖了ExtJS的核心部分。通过深入研究这个压缩包中的内容,开发者不仅可以掌握ExtJS的基本用法,还能了解到高级特性和最佳实践,从而在Web开发领域取得更大...

    extjs-docs-6.0.0-classic.part01.rar

    Ext JS 6最大的变化就是将Ext JS和Touch合并为一个单一的框架。之前的框架的核心(数据、控制器、模型等等)已被调和为一个单一的公共平台。这样,数据和逻辑就能共享,从而帮助开发人员进一步去优化他们的应用程序...

    ExtJS-MVC-用户列表实例

    总结起来,这个"ExtJS-MVC-用户列表实例"展示了如何使用ExtJS的MVC架构来构建一个功能完整的Web应用,包括定义数据模型、创建视图来展示数据、设置控制器来处理用户交互,以及利用Store进行数据管理。同时,...

    Extjs-ext-3.1.1

    licensing@extjs.com http://extjs.com/license Open Source License Ext is licensed under the terms of the Open Source GPL 3.0 license. http://www.gnu.org/licenses/gpl.html There are several FLOSS ...

    ExtJS----HelloWorld程序源码

    在"ExtJS----HelloWorld程序源码"中,我们将会看到如何使用ExtJS来创建一个简单的“你好,世界!”应用。以下是对这个示例中涉及的主要知识点的详细解释: 1. **引入ExtJS库**:首先,你需要在HTML文件中引入ExtJS...

    ExtJS入门教程-超级详细-共36页 完整版 PDF

    ExtJS入门教程-超级详细-共36页 完整版 PDF,电子书方便阅读和分享。

    extjs-620-docs-离线文档

    extjs-620-docs,6.2.0离线文档,解压后可以布署到web服务器

    extjs-3.0-all-src

    总之,"extjs-3.0-all-src"包含的是ExtJS 3.0的全部源代码,对学习和研究该框架的实现原理以及定制开发非常有帮助。通过理解和掌握这些知识点,开发者可以利用ExtJS 3.0创建功能强大、用户体验优秀的Web应用程序。

Global site tag (gtag.js) - Google Analytics