```var storeCfg = {
url : actionName + '?method=findAllUserByLoginUser',
totalProperty : 'total',
successProperty : 'success',
root : 'voRecords',
fields : [ 'userId', 'userAccount', 'empId', 'userName',
'userStatus', 'userType', 'remark', {
name : "timeStamp",
mapping : "timeStamp",
convert : function(v, record) {
return v.split('T')[0];
}
}, 'orgId', 'orgName', 'deptName', 'positionName', {
name : "expireDate",
mapping : "expireDate",
convert : function(v, record) {
if (v != null) {
return v.split('T')[0];
} else {
return '';
}
}
}, 'mac1', 'mac2', 'position', 'phone', {
name : "passEndDate",
mapping : "passEndDate",
convert : function(v, record) {
if (v == null) {
return '';
} else {
return v.split('T')[0];
}
}
}, {
name : "isExport",
mapping : "isExport"
} ]
};
var jsonReader = new Ext.data.JsonReader(storeCfg);
var dataStore = new Ext.data.JsonStore(storeCfg);
var results = [
{
id : 'userId',
header : '用户主键',
dataIndex : 'userId',
hidden : true
},
{
id : 'userAccount',
header : '用户号',
dataIndex : 'userAccount',
width : 100
},
{
id : 'userName',
header : '用户名称',
dataIndex : 'userName',
width : 100
},
{
id : 'orgName',
header : '机构名称',
dataIndex : 'orgName',
width : 120
},
{
id : 'deptName',
header : '部门名称',
dataIndex : 'deptName',
width : 120
},
{
id : 'roleName',
header : '角色名称',
dataIndex : 'roleName',
width : 120,
renderer : function(value) {
if (value == '')
return '正常';
else
return '未分配角色';
}
},
{
id : 'userStatus',
header : '是否锁定',
dataIndex : 'userStatus',
width : 70,
renderer : function(value) {
if (value == '0')
return '正常';
else if (value == '1')
return '锁定';
}
},
{
id : 'timeStamp',
header : '创建日期',
dataIndex : 'timeStamp',
width : 85
},
/*
{
id : 'expireDate',
header : '过期日期',
dataIndex : 'expireDate',
width : 85
}, */
{
id : 'mac1',
header : 'MAC1',
dataIndex : 'mac1',
hidden : true,
width : 120
},
{
id : 'mac2',
header : 'MAC2',
dataIndex : 'mac2',
hidden : true,
width : 120
},
{
id : 'positionName',
header : '职位',
dataIndex : 'positionName',
width : 120
},
{
id : 'phone',
header : '联系电话',
dataIndex : 'phone',
width : 120
},
{
id : 'isExport',
header : '登陆系统方式',
dataIndex : 'isExport',
width : 90,
renderer : function(value, cellmeta, record, rowIndex,
columnIndex, store) {
if ('0' == value) {
return '本系统登陆';
} else if ('1' == value) {
return 'Portal登陆';
} else {
return '两者均可';
}
}
}, {
id : 'remark',
header : '备注',
dataIndex : 'remark',
width : 120
} ];
var btn_add = new Ext.Button( {
text : '添加',
iconCls : 'icon-add',
handler : function() {
/*
* Ext.Ajax.request({ url: actionName +
* '?method=findOrgNameById&oId=0', params : { id:0 }, success :
* function(response,options) { //
* Ext.getCmp('updatekeyWord').setValue(response.responseText);
*
*
* },failure: function(form, action) { Ext.Msg.show( { title :
* '错误提示', msg : action.result.error.message, buttons :
* Ext.Msg.OK, icon : Ext.Msg.ERROR } ); } } );
*/
window_add.show(); // 点击按钮后显示新增窗体
orgId.setRawValue('');
orgid_hidden.setRawValue('');
}
});
用JSON数组是不是有点复杂,可不可以考虑直接用JSON呢?
你这段代码里唯一可能跟后台交互的部分还是注释掉的,你确定这段代码和后台有交互吗?
url : actionName + '?method=findAllUserByLoginUser',
ajax加载的,你自己下个ext的api好好看下,返回的数据要和你gridpanel配置的columns一样,要不无法加载数据
这个是你的请求地址。url : actionName + '?method=findAllUserByLoginUser',
可以在action中调试一下。看结果是啥,上面的
{
id : 'userId', //表示id
header : '用户主键', //页面显示
dataIndex : 'userId', //读取对应这个键的值
hidden : true //隐藏
},
{
id : 'userAccount',
header : '用户号',
dataIndex : 'userAccount',
width : 100
},
这些是框架自身的格式要求,你看看你的返回,应该是一个json数组,里面有userId,userAccount的键值对。