Over the past 4 years, the Ext JS codebase has evolved; new components have been added and coding standards have improved. During this process, it was necessary to go back every so often to refactor older components and keep processes in sync.
在过去的4年里,Ext js的代码库不断在发展,新的组建不断被添加,编码标准也在不断的改进。在这期间,一个很重要的事情就是必须不断的重构较旧的组件以保持同步。
Until Ext JS 4, there has been no standard way to render components. In the past, Panels rendered primarily by creating the elements they needed and adding them to the dom directly, picking up references along the way. Fields on the other hand, manipulated the autoEl DomHelper configuration and then wrapped specific html fragments as needed. Grids made extensive use of templates to build up their markup and inject it into the page.
在Ext js 4之前,渲染组件并没有统一标准的方式。Panels的主要渲染方式是创建它们所需的元素并直接添加到DOM节点上。而Fields的渲染,则是通过配置DomHelper的autoEI,然后通过包裹特定HTML片段实现的。Grids则主要通过模版建立元件,然后渲染到页面。
For Ext JS 4, our goal is to unify these techniques into one cohesive standard by leveraging XTemplate and DomQuery. This standard is easy to work with and allows developers the flexibility required to develop robust components. This standard will be used internally across all of our components.
在Ext JS 4,我们的目标是将这些渲染方法统一为使用XTemplate和DomQuery进行渲染。该渲染方法不单易于使用,而且让开发人员在开放自己的组件时更灵活。该渲染方法将成为所有组件的标准渲染方式。
Introducing renderTpl, renderData, and renderSelector
介绍renderTpl,renderData和renderSelector
All components in Ext JS 4 are rendered with a base div element which provides a unique id, and baseline component classes (cls, cmpCls, baseCls, and ui). If additional elements are needed to create a component, they are now handled with an XTemplate (renderTpl). Data for the XTemplate is read from a renderData object and Ext.Element references can be placed on the component instance via renderSelectors. The renderSelector is scoped from the base div element and uses standard css selectors. These Ext.Element references are part of the component lifecycle and removed automatically when the component is destroyed. The following example will help illustrate the creation of a custom component:
Ext JS 4的所有组件都会被渲染成一个带有id的div元件和基类组件(cls、cmpCls和ui)。如果创建一个组件需要额外的元件,那么它将通过XTemplate (renderTpl)来处理。XTemplate所需的数据将通过 renderData对象读取,并在组件实例中通过renderSelectors方法创建一个Ext.Element对象。renderSelector使用标准的css选择器,其作用范围是基本的div元件。这些Ext.Element对象将作为组件生命周期的一部分,直到组件被销毁时才自动销毁。下面的例子将有助于说明如何创建定制组件:
Simple custom icon component example:
简单的自定义图标组件的例子:
IconComponent = Ext.extend(Ext.Component, {
iconCls: 'myIcon',
renderTpl: '
" src="{blank}
" class
="{iconCls}
"/>',
initComponent: function
() {
Ext.applyIf(this
.renderData, {
blank: Ext.BLANK_IMAGE_URL,
iconCls: this
.iconCls
});
Ext.applyIf(this
.renderSelectors, {
iconEl: '.' + this
.iconCls
});
IconComponent.superclass.initComponent.call(this
);
},
changeIconCls: function
(newIconCls) {
if
(this
.rendered) {
this
.iconEl.replaceClass(this
.iconCls, newIconCls);
}
this
.iconCls = newIconCls;
}
});
The renderTpl defines an XTemplate with “blank” and “iconCls” variables which are read from renderData at render time. In addition, an “iconEl” reference to the Ext.Element is applied to the instance at render time. The changeIconCls method can now use the iconEl as soon as the component has been rendered.
renderTpl 定义了一个XTemplate对象,它有两个需要在渲染时从renderData 获取数据的变量“blank”和“iconCls”的。此外,在渲染时,将在实例中创建一个“iconEl”的Ext.Element对象。当组件渲染完成时,在changeIconCls方法将可以使用“iconEl ”对象。
原文:http://www.sencha.com/blog/2010/12/13/ext-js-4-preview-refactoring-standardizing-the-rendering-process/
分享到:
相关推荐
4. **性能提升**:Ext JS 4在渲染速度、内存管理和响应时间上进行了大量优化,提高了用户体验。 5. **更好的文档和支持**:官方提供了详尽的文档和API参考,以及活跃的社区支持,帮助开发者快速解决问题。 三、从...
### Ext JS 4.0 编码规范详解 #### 一、环境要求 Requirements ##### 1. 浏览器 Web Browsers Ext JS 4.0 支持主流浏览器,确保了良好的兼容性和广泛的用户覆盖。为了获得最佳的调试体验,推荐使用以下浏览器: - ...
本压缩包包含EXT JS的多个版本源码,如ext-3.2.0、ext3.3.1和ext4,以及对应的中文API文档和实用学习资料,对于想要深入理解EXT JS或提升EXT JS开发技能的人来说是宝贵的资源。 一、EXT JS 源码分析 EXT JS 的源码...
包含3个工具:make_ext4fs、simg2img、kusering.sh。 1. 解压system.img为system.img.ext4。命令:simg2img system.img system.img.ext4 2. 创建system.img.ext4挂载目录tmp; 命令:mkdir tmp; 3. 挂载system....
这几天训网络最困扰我的问题就是服务器...EXT4-fs error (device sda1): ext4_lookup:1593: inode #6004222: comm trash-expunge: deleted inode referenced: 6004301 类似这样的错误,看样子是sda1磁盘文件系统的问题
EXT,全称Ext JS,是一款基于JavaScript的开源前端框架,主要用来构建富互联网应用程序(RIA)。在EXT中,处理图片上传并实现预览功能是一项常见的需求,尤其在用户交互丰富的应用中,允许用户在正式上传前预览图片...
《深入理解ext4_utils:三星线...在三星线刷ROM的制作过程中,ext4_utils确保了文件系统的创建、调整和维护,从而保证了系统的稳定性和高效性。理解并熟练使用这些工具,对于提升开发效率和保障系统质量具有重要意义。
4. **不用写JavaScript的EXT应用**:"一个不用写javascript的ext综合应用-简易java框架- BlogJava.zip"可能是一个简化了JavaScript编程的解决方案,通过Java后端生成Ext JS代码,使得开发者可以更专注于业务逻辑,而...
在数据传输过程中,Ext JS提供了Ajax请求(Ext.Ajax)和Direct(Ext.direct)两种主要方式。Ajax请求用于与服务器进行异步通信,支持GET、POST、PUT、DELETE等多种HTTP方法,可以发送JSON、XML等格式的数据。Direct...
本书从基础的JavaScript知识点开始,逐步过渡到Ext JS 4的面向对象编程概念,重点介绍了Ext JS的UI组件、布局以及核心功能,包括MVC架构、应用程序的主题与样式设计、以及如何通过网格、树形控件和图表等组件展示...
Ext JS是一个功能丰富的JavaScript框架,用于构建交互式的Web应用程序。它提供了大量的UI组件,这些组件都遵循一定的生命周期,包括创建、渲染和销毁。Xtype在Ext JS中扮演着至关重要的角色,它是组件类型的标识符,...
EXT JS 是一个强大的JavaScript前端框架,专用于构建富客户端应用。EXT JS 4 版本在日期控件方面提供了丰富的功能,使得开发者可以方便地处理日期和时间输入。在这个特定的资源中,我们关注的是一个集成时间选择的...
`Ext.Loader` 是 Ext4 中的一个核心特性,用于动态加载所需的 JavaScript 类库和模块,这在开发大型应用时尤其有用,因为它可以显著减少页面初次加载时的资源需求。 动态加载的核心在于按需加载,即只有在实际需要...
本文将深入探讨如何使用`ext4-utils`工具集来创建`make_ext4fs`和`simg2img`这两个关键工具,这对于理解Android系统底层工作原理以及进行相关开发和调试非常有帮助。 `make_ext4fs`是一个用于创建ext4文件系统的...
Ext JS 是一款基于 JavaScript 的前端框架,主要用于构建复杂的企业级 Web 应用程序。它提供了一套丰富的 UI 组件库以及一系列用于数据处理、应用架构设计等功能模块。自发布以来,Ext JS 不断迭代更新,版本4(Ext ...
Ext JS 是一个强大的JavaScript库,专门用于构建富客户端Web应用程序。这个库以其丰富的用户界面组件、数据绑定功能和可扩展性而闻名。Ext JS 提供了一整套预先封装的组件,如表格、面板、菜单、按钮、表单、树形...
Spket是这样一个专门针对JavaScript和相关技术(如Ajax、DWR和JSON)的IDE,它支持Ext JS的开发。Spket提供了一套强大的特性,帮助开发者更高效地编写代码,包括代码提示、自动完成、错误检查和调试功能。 1. **Ext...
1. **组件体系**:EXT JS的组件模型是其强大之处,理解组件的生命周期、渲染过程、属性和方法对于创建自定义组件至关重要。 2. **数据绑定**:EXT JS的数据绑定机制允许UI与后台数据模型实时同步,这是实现动态、...