Extjs 项目中常用的小技巧,也许你用得着(4)---Extjs 中的cookie设置

简介: 1.ExtJs设置cookie两种方式 其一:设置cookie如下 saveacct=isForm.getForm().findField('itemselector').getValue(); Ext.

1.ExtJs设置cookie两种方式

其一:设置cookie如下

saveacct=isForm.getForm().findField('itemselector').getValue();
 Ext.util.Cookies.set('saveacct',saveacct);

 取cookie中数据如下

var validStatus = Ext.util.Cookies.get("saveacct");
alert(validStatus);

 

 其二:设置cookie

var cookie = new Ext.state.CookieProvider();  
 Ext.state.Manager.setProvider(cookie);  
  cookie.set('saveacct',saveacct); 

取cookie中数据如下

var cookie1 = Ext.state.Manager.getProvider();
  var getsaveacct = cookie1.get('saveacct'); 

第一个只在同一界面中生效,跨越界面是取不到cookie中的值,可能是path路径设的不对。

而第二个设定后,全局都可使用。但是在设置之前需要clear一下。

 2.设置文本标签靠右:

labelAlign:'right',

3.把文本框变成密码输入框

inputType: 'password',

例子:

                  {
                    id: 'newpassword',
                    xtype: 'textfield',
                    anchor: '80%',
                    fieldLabel: '新密码',
                    labelAlign: 'right',
                    inputType: 'password',
                }

4.禁用文本框

  readOnly: true

例子

{
            id: 'editName',
            xtype: 'textfield',
            labelAlign:'right',
            anchor: '80%',
            //align:right,
            fieldLabel: '用户名:',
            value: Ext.util.Cookies.get("UserName"),
            readOnly: true
        }

密码修改图为:

5.调整表单控件之间的间距

           {
                id: 'editName',
                xtype: 'textfield',
                labelAlign: 'right',
                anchor: '80%',
                //align:right,
                fieldLabel: '用户名:',
                value: Ext.util.Cookies.get("UserName"),
                readOnly: true,
                padding:20
            }

设置padding属性,就可以了

改后如图:

6.Extjs gridpanel的单元格的数据怎么居中显示

 

设置align属性为center就行了,效果如下:

 

目录
相关文章
|
2月前
|
安全 PHP
从建站到拿站 -- PHP(Cookie设置)
从建站到拿站 -- PHP(Cookie设置)
20 0
|
2月前
|
存储 开发框架 NoSQL
ASP.NET WEB——项目中Cookie与Session的用法
ASP.NET WEB——项目中Cookie与Session的用法
29 0
|
7月前
|
XML 开发框架 Java
Java Web 项目入门指南(http、Servlet、Request、Response、ServletContext、会话技术[cookie、session]、Filter、Listener)
Java Web 项目入门指南(http、Servlet、Request、Response、ServletContext、会话技术[cookie、session]、Filter、Listener)
|
8月前
|
JavaScript
js设置、修改、获取、删除 cookie
js设置、修改、获取、删除 cookie
119 0
|
4月前
|
存储 JavaScript PHP
什么是cookie,如何设置在浏览器页面关闭后清除cookie
什么是cookie,如何设置在浏览器页面关闭后清除cookie
93 0
|
4月前
|
存储 JavaScript 前端开发
百度搜索:蓝易云【php设置和获取Cookie教程。】
需要注意的是,为了确保在向浏览器发送任何输出之前设置Cookie,应该在 `<html>`标签之前或PHP脚本的顶部设置Cookie。
73 0
|
4月前
【博客项目】—cookie和session(七)
【博客项目】—cookie和session(七)
|
10月前
|
存储 缓存 JSON
36.从入门到精通:CGI环境变量 GET和POST方法 GET方法 POST方法 CGI中使用Cookie Cookie设置 检索Cookie信息
36.从入门到精通:CGI环境变量 GET和POST方法 GET方法 POST方法 CGI中使用Cookie Cookie设置 检索Cookie信息
|
6月前
|
存储
83分布式电商项目 - Cookie存储购物车
83分布式电商项目 - Cookie存储购物车
18 0
|
7月前
|
XML 监控 Java
Java Web 项目入门指南(http、Servlet、Request、Response、ServletContext、会话技术[cookie、session]、Filter、Listener)4
Java Web 项目入门指南(http、Servlet、Request、Response、ServletContext、会话技术[cookie、session]、Filter、Listener)4