- 浏览: 207001 次
- 性别:
- 来自: 北京
最新评论
-
Relucent:
likaiyihou51 写道The constructor ...
获得Hibernate Criteria实际SQL的方法 -
likaiyihou51:
The constructor CriteriaJoinWal ...
获得Hibernate Criteria实际SQL的方法 -
likaiyihou51:
大侠 我copy了这个代码 又个问题,能给看一下吗
获得Hibernate Criteria实际SQL的方法 -
haisee:
管用,Firefox和Chrom验证通过。
Javascript设置和获取Textarea的光标位置的方法 -
wanghaosvse:
请问楼主,有没有跟数据库同步的动态加载
带选择框的JS树控件2 (为JSTree再次提速)
ExtJs 中,我们使用GirdPanel的时候往往需要给后台传递查询条件。
一般是通过修改Store的baseParams。
var store = GirdPanel.getStore(); store.baseParams = { 查询条件 } store.reload(); //刷新表格
这个方法在ExtJs 2.x 和 ExtJS 3.0.0 中都使用。
但是当使用ExtJS 3.1.0的时候,问题就出现了。
我们会发现无论如何修改baseParams,查询条件依然还是第一次修改baseParams时候的条件。
所以我们无法通过修改baseParams 来满足修改查询条件的目的。
于是我们观察ExtJS 3.1.0源码发现
reload : function(options){ this.load(Ext.applyIf(options||{}, this.lastOptions)); }
这里我们要说一下lastOptions的作用。
lastOptions用于保留最后一次的查询配置信息。
我们再去跟踪其他部分的代码。
这个是load的时候的代码。
我们可以看到首先使用storeOptions 方法保存了最后一次的查询条件。然后在调用execute执行查询。
load : function(options) { options = options || {}; this.storeOptions(options); if(this.sortInfo && this.remoteSort){ var pn = this.paramNames; options.params = options.params || {}; options.params[pn.sort] = this.sortInfo.field; options.params[pn.dir] = this.sortInfo.direction; } try { return this.execute('read', null, options); // <-- null represents rs. No rs for load actions. } catch(e) { this.handleException(e); return false; } },
storeOptions : function(o){ o = Ext.apply({}, o); delete o.callback; delete o.scope; this.lastOptions = o; },
execute : function(action, rs, options, /* private */ batch) { if (!Ext.data.Api.isAction(action)) { throw new Ext.data.Api.Error('execute', action); } options = Ext.applyIf(options||{}, { params: {} }); if(batch !== undefined){ this.addToBatch(batch); } var doRequest = true; if (action === 'read') { Ext.applyIf(options.params, this.baseParams); doRequest = this.fireEvent('beforeload', this, options); } else { if (this.writer.listful === true && this.restful !== true) { rs = (Ext.isArray(rs)) ? rs : [rs]; } else if (Ext.isArray(rs) && rs.length == 1) { rs = rs.shift(); } if ((doRequest = this.fireEvent('beforewrite', this, action, rs, options)) !== false) { this.writer.apply(options.params, this.baseParams, action, rs); } } if (doRequest !== false) { if (this.writer && this.proxy.url && !this.proxy.restful && !Ext.data.Api.hasUniqueUrl(this.proxy, action)) { options.params.xaction = action; } this.proxy.request(Ext.data.Api.actions[action], rs, options.params, this.reader, this.createCallback(action, rs, batch), this, options); } return doRequest; },
我们重点关注
storeOptions 方法中的 o = Ext.apply({}, o);
和
execute 的 Ext.applyIf(options.params, this.baseParams);
他的目的是这样的。
首先
[storeOptions ]
克隆一个新的 Options ,并保存到lastOptions中。
lastOptions使用新的Options的目的是原有Options发生变化lastOptions不变。
[execute ]
然后将baseParams的内容添加到Options.params中,并使用Options.params作为参数进行查询。
逻辑上没有错误
是将baseParams内容添加到原有的Options.params中。
新的lastOptions(Options2)内容不变。(因为是克隆的)
但是实际上Options.params发生变化的而同时。lastOptions中的params也发生了变化。
原因在storeOptions 方法上。
o = Ext.apply({}, o);
做的只是一个浅层拷贝。拷贝之后
lastOptions.params 和 Options.params 其实是一个对象。
所以当Options.params发生变化lastOptions.params也发生变化。
(不知道是Jack Slocum故意这么设计的还是没有考虑周全,不过这造成了版本的不兼容)
原因找到了,修改起来也就容易了。我们只需要重构storeOptions 方法,将其params也拷贝一次就可以了。
Ext.override(Ext.data.Store, { storeOptions : function(o) { o = Ext.apply({}, o); if(o.params) o.params = Ext.apply({}, o.params); } delete o.callback; delete o.scope; this.lastOptions = o; } });
评论
<p>Loads the Record cache from the configured proxy using the configured reader.</p>
<p> </p>
<p><strong>Notes</strong>:</p>
<p style="padding-left: 30px;"> </p>
<ul>
<li>Important: loading is asynchronous! This call will return before the new data has been loaded. To perform any post-processing where information from the load call is required, specify the callback function to be called, or use a a 'load' event handler.</li>
<li>If using remote paging, the first load call must specify the start and limit properties in the options.params property to establish the initial position within the dataset, and the number of Records to cache on each read from the Proxy.</li>
<li>If using remote sorting, the configured sortInfo will be automatically included with the posted parameters according to the specified paramNames.</li>
</ul>
<p> </p>
<p><strong>Parameters</strong>:</p>
<p> </p>
<p><strong>options</strong> : Object</p>
<p style="padding-left: 30px;">An object containing properties which control loading options:</p>
<p> </p>
<p style="padding-left: 30px;">params :Object</p>
<p style="padding-left: 60px;">An object containing properties to pass as HTTP parameters to a remote data source. Note: params will override any baseParams of the same name.</p>
<p style="padding-left: 60px;">Parameters are encoded as standard HTTP parameters using Ext.urlEncode.</p>
<p style="padding-left: 30px;"> </p>
<p style="padding-left: 30px;">callback : Function</p>
<p style="padding-left: 60px;">A function to be called after the Records have been loaded. The callback is called after the load event is fired, and is passed the following arguments:</p>
<p style="padding-left: 90px;">r : Ext.data.Record[] An Array of Records loaded.</p>
<p style="padding-left: 90px;">options : Options object from the load call.</p>
<p style="padding-left: 90px;">success : Boolean success indicator.</p>
<p style="padding-left: 30px;"> </p>
<p style="padding-left: 30px;">scope : Object</p>
<p style="padding-left: 60px;">Scope with which to call the callback (defaults to the Store object)</p>
<p style="padding-left: 30px;"> </p>
<p style="padding-left: 30px;">add : Boolean</p>
<p style="padding-left: 60px;">Indicator to append loaded records rather than replace the current cache. Note: see note for loadData</p>
<p> </p>
发表评论
-
【转】Closure Compiler 高级模式及更多思考(js文件压缩工具 )
2011-03-16 13:05 1955【转】Closure Compiler 高级模式及更多思考 ... -
Base64编码解码(JavaScript版本)
2010-12-17 10:24 2792<html> <HTML> < ... -
JavaScript 中2个等号与3个等号的区别
2010-12-07 13:21 25324首先,== equality 等同,=== identity ... -
JS前端获取上传文件的大小的方法
2010-11-01 11:04 23480WEB应用中,经常会遇到上传附件的问题,比如有时候会有限制附件 ... -
Javascript设置和获取Textarea的光标位置的方法
2010-07-20 11:05 6599<html><head> <m ... -
JavaScript JSON 对象深拷贝方法(一例)
2010-07-14 20:08 6465其实深拷贝一个JS对象方法十分简单,只需要两部 1.首先将J ... -
关于Extjs异步session超时问题处理
2010-07-08 17:46 4001关于Extjs异步session超时问题处理对于HTTP超时的 ... -
ExtJS 的组建扩展方法
2010-07-08 17:19 2224ExtJS 是一个不错的JS 类库,提供了很多组建。 ... -
JS 地图移动拖拽
2010-05-26 09:06 2770很简单的东东,就是类似google地图那样,可以拖拽图片。 ... -
JS移动的方块
2010-05-21 09:00 1362PS:WASD上下左右,双击加速. 同时按下WASD任意2个按 ... -
JS对象序列化为JSON对象
2010-04-17 10:07 10603/** * JSON 解析类 * Copyright ... -
JavaScript日期格式化
2010-03-17 11:17 1554DateFormat = (function(){ ... -
Ext智能提示 - Spket(Eclipse插件)
2009-10-23 13:01 1977Spket是Eclipse的一个插件,RIA的开发工具。支持J ... -
带选择框的JS树控件2 (为JSTree再次提速)
2009-10-14 12:00 9497以前写过一个带选择框的JS树控件 但是当时发现一个问题,第一次 ... -
带选择框的JS树控件
2009-10-12 11:09 2079前阵子自己写了个带选择框的tree控件,虽然还有一些bug没有 ... -
多附件上传
2008-10-29 23:48 1480uploads.js var UploadBuilder=(f ... -
HTML通过button触发input-file控件上传文件的问题
2008-10-20 10:32 25571出于安全方面的考虑,通过JS修改input-file的valu ... -
模拟线程Timer(JS)
2008-09-22 09:06 1862<script language="Java ... -
转换Unicode (JS)
2008-09-02 17:34 2594<html> <head> ... -
JS-Cookie
2008-08-05 11:33 1321/** * cookie管理对象 */ Cook ...
相关推荐
关于这个原因有很多种,我只说下我遇到的 我这样 写Store来复用的 代码如下: DocStore = Ext.extend(Ext.data.Store,{ initComponent:function(){ this.proxy = new Ext.data.HttpProxy({url:this.url}); this....
extjs多选下拉框,Ext.ux.form.LovCombo,extjs 以修复多选下拉框火狐下取不到值的问题,火狐下div不显示背景色的问题
代码如下: var Store = Ext.create(‘Ext.data.Store’, { pageSize: pageSize, model: ‘Ext.data.Model名称’, autoLoad: false, proxy: { type: ‘ajax’, url: ‘请求路径’, getMethod: function(){ return ...
NULL 博文链接:https://maoyi606.iteye.com/blog/1782825
6. Ext.data.Store篇 10 7. Ext.data.JsonReader篇一 12 8. Ext.data.JsonReader篇二 15 9. Ext.data.HttpProxy篇 19 10. Ext.data.Connection篇一 20 11. Ext.data.Connection篇二 24 12. Ext.Updater篇一 26 13. ...
NULL 博文链接:https://atian25.iteye.com/blog/1019910
Extjs4.1多个扩展 1、Ext.ux.aceeditor.Panel 2、Ext.ux.grid.feature.Tileview 3、Ext.ux.upload.Button 4、Ext.ux.toggleslide.ToggleSlide 5、Ext.ux.container.ButtonSegment 6、Ext.ux.grid.plugin.RowEditing ...
6. Ext.data.Store篇 10 7. Ext.data.JsonReader篇一 12 8. Ext.data.JsonReader篇二 15 9. Ext.data.HttpProxy篇 19 10. Ext.data.Connection篇一 20 11. Ext.data.Connection篇二 24 12. Ext.Updater篇一 26 13. ...
ExtJs学习资料28-Ext.data.JsonStore数据存储器
主要用例子说明extjs4的form表单的运用,其中有表单属性说明,表单控件运用说明如: title:'表单', //表单标题 bodyStyle:'padding:5 5 5 5', //表单边距 height:120, //表单高度 width:200, //表单宽度 ...
代码如下: Ext.onReady(function() { Ext.Msg.alert(‘提示’, ‘逗号分隔参数列表’); //这种方式非常常见的 }); 效果图: 代码如下: Ext.onReady(function() { //定义 JSON(配置对象) var config = { ...
最新的Extjs3.1.0官网下载完整版本, 外带Extjs中文文档做参考 欢迎交流: QQ168052704
主要介绍了ExtJs的Ext.Ajax.request实现waitMsg等待提示效果,需要的朋友可以参考下
该ext.jsb2文件是ExtJS3.4.0中的,因ExtJS4.0.0中没有这个文件,但可以与4.0.0版本共用。
ExtJS tooltip功能组件实例
EXTjs的上传组件
extjs 可编辑的表格树,每个单元格自定义编辑组件,可以自适应列宽,只有源码与例子,运行实例要修改路径,不然图片不能显示,注意etree.jsp的js引入路径 支持Ext2.x以上版本 如运行不了EmailTo : codeme9@gmail....