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

Javascript
javascript radio 联动效果
兼容FireFox 的 js 日历 支持时间的获取
小型js框架veryide.librar源代码
js 颜色选择器(兼容firefox)
Iframe thickbox2.0使用的方法
JavaScript RegExp方法获取地址栏参数(面向对象)
javascript prototype 原型链
动态添加js事件实现代码
IE6、IE7、Firefox javascript 无提示关闭窗口的代码
JavaScript 事件属性绑定带参数的函数
InnerHtml和InnerText的区别分析
javascript radio值获取代码
用JavaScript编写COM组件的步骤
javascript 避免闭包引发的问题
js no-repeat写法 背景不重复
javascript 回车键后跳到下一控件
javascript IE7 浏览器本地图片预览
javascript attachEvent和addEventListener使用方法
JavaScript 脚本将当地时间转换成其它时区
javascript 装载iframe子页面,自适应高度

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


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