当前位置: 首页 > 图文教程 > 网络编程 > Javascript > javascript Ext JS 状态默认存储时间

Javascript
编写跨浏览器的javascript代码必备[js多浏览器兼容写法]
JS Array对象入门分析
javascript typeof的用法与typeof运算符介绍[详细]
js CSS操作方法集合
让任务管理器中的CPU跳舞的js代码
ajax无刷新动态调用股票信息(改良版)
js Clip的奇思妙想之文字拼接效果
js Clip奇思妙想之多彩渐变字效果
JS 创建对象(常见的几种方法)
JS中字符问题(二进制/十进制/十六进制及ASCII码之间的转换)
JS提交并解析后台返回的XML的代码
初学Javascript的一些总结
JS 继承实例分析
js form action动态修改方法
仿163填写邮件地址自动显示下拉(无优化)
js判断对象是否是某一类型
解决extjs在firefox中关闭窗口再打开后iframe中js函数访问不到的问题
js 目录列举函数
js颜色选择器代码[firefox不支持]
js wmp操作代码小结(音乐连播功能)

Javascript 中的 javascript Ext JS 状态默认存储时间


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 313 ::
收藏到网摘: n/a

通过ExtJS的源码可以知道,ExtJS将Grid的自定义显示列等自定义状态信息存入Cookie中,默认时间为7天
复制代码 代码如下:

Ext.state.CookieProvider = function(config){
Ext.state.CookieProvider.superclass.constructor.call(this);
this.path = "/";
this.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); //7 days
this.domain = null;
this.secure = false;
Ext.apply(this, config);
this.state = this.readCookies();
};
Ext.state.CookieProvider = function(config){
Ext.state.CookieProvider.superclass.constructor.call(this);
this.path = "/";
this.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); //7 days
this.domain = null;
this.secure = false;
Ext.apply(this, config);
this.state = this.readCookies();
};

我们可以通过设定expires的值来改变默认的存储时间,比如:
复制代码 代码如下:

this.expires: new Date(new Date().getTime()+(1000*60*60*24*365)), //一年
this.expires: new Date(new Date().getTime()+(1000*60*60*24*365)), //一年

或者我们可以在开始位置的Ext.onReady函数中加上以下的代码
复制代码 代码如下:

Ext.state.Manager.setProvider(
new Ext.state.CookieProvider({
expires: new Date(new Date().getTime()+(1000*60*60*24*365)), //一年
}));