用Ext做项目,总结的一些属性针对不同控件
1.grid 中,编辑表格内容时的点击变输入框
plugins: [cellEditing] //点击变输入框
columns:[{ //在需要变书入框的列中加入以下需要的类型
field: {
xtype: 'datefield'
}
}]
2.输入框内容验证
msgTarget: 'side', //错误显示叹号 validator: function (value) { //验证内容 if (value > 0 && value <= 1) { return true; } }
3.只可操作当前窗口(在页面中弹出小窗口)
modal:true //只可操作当前窗口,在弹出窗口中必不可少的属性
4.gridPanel 中默认会有列排序的功能
menuDisabled : true, //隐藏gridPanel中排序和列菜单按钮
5. grid 需要的分页控件
dockedItems: [{ //gridPanel 分页 xtype: "pagingtoolbar", store: store, //获得的分页数据 dock: "bottom", displayInfo: true }]
6. gridPanel 中设置 align:'center '表头和表格体中的内容都会居中。但有时需要表头内容居中,表格体内容居左,那就要这样写了
columns:[{
header:'<div style="text-align:center">编号</div>', //gridPanel中表头居中内容居左
align: 'left'
}]
7. extjs 中的文字是默认不能被选中的
viewConfig:{ enableTextSelection:true //grid中文本可以被选中 },
8.grid单元格文字换行
renderer : function (value, meta, record) { meta.style = 'white-space:normal;word-break:break-all;'; return value; }
11. JSON 与Object 格式转换
Ext.JSON.decode(String json); //返回 Object
Ext.JSON.encode(Object o); //返回String
13、常用正则
//验证中文姓名正则 var nameREG = /^[u4e00-u9fa5]{2,4}$/; //验证身份证号正则 var idcardREG = /(^d{15}$)|(^d{18}$)|(^d{17}(d|X|x)$)/; //验证手机号正则 var phoneREG = /^1[3|5|7|8|][0-9]{9}$/;