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

Javascript
js select 标签选定项的值获取代码
js GridView 实现自动计算操作代码
Discuz 公告效果(自动换行,无间隙滚动)
js 动态添加标签(新增一行,其实很简单,就是几个函数的应用)
JS 常用校验函数
HTML代码中标签的全部属性 中文注释说明
input 高级限制级用法
js onpropertychange输入框 事件获取属性
Javascript 生成无限下拉列表实现代码
javascript 极速 隐藏/显示万行表格列只需 60毫秒
用JavaScript实现单继承和多继承的简单方法
javascript 闭包函数做显隐内容
js 页面模块自由拖动实例
js Flash插入函数免激活代码
setTimeout 不断吐食CPU的问题分析
说说掌握JavaScript语言的思想前提想学习js的朋友可以看看
js 浏览器版本及版本号判断函数2009年
Javascript 原型和继承(Prototypes and Inheritance)
HTML 自动伸缩的表格Table js实现
两个INPUT同步输入的方法小结 兼容IE和firefox

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 310 ::
收藏到网摘: 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)), //一年
}));