UserInfoGridPanel = Ext.extend(Ext.grid.GridPanel,{
myid: "my_id",
addWin: null,
editWin: null,
//构造方法
constructor: function(_cfg){
if(_cfg == null){
_cfg = {};
}
Ext.apply(this,_cfg);
//将AddUserInfoWindow的引用赋值给当前属性addWin
//this.addWin = new AddUserInfoWindow();
//this.editWin = new EditUserInfoWindow();
//数据存储器
this["store"] = new Ext.data.JsonStore({
url: 'userInfo.action?method=showInfoByPage',
totalProperty: "totalCount",
root: "rows",
fields: ["userId","userName","password","contactTel","email","creatDate"]
});
//将父类的构造方法Copy过来
UserInfoGridPanel.superclass.constructor.call(this,{
id: this.myid,
title: "用户信息列表",
border: false,
iconCls: "houfei-treeNodeLeafIcon",
stripeRows: true, //交替行效果
viewConfig:{
autoFill: true,
forceFit: true
},
//列模版
colModel: new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),{
header: "编 号",
sortable: true, //允许排序
align:'center',
dataIndex: "userId"
},{
header: "帐 号",
sortable: true, //允许排序
align:'center',
dataIndex: "userName"
},{
header: "密 码",
sortable: true, //允许排序
align:'center',
dataIndex: "password"
},{
header: "手 机 号 码",
sortable: true, //允许排序
align:'center',
dataIndex: "contactTel"
},{
header: "邮 箱",
sortable: true, //允许排序
align:'center',
dataIndex: "email"
},{
header: "创 建 时 间",
sortable: true, //允许排序
align:'center',
dataIndex: "creatDate"
}]),
//填充加载时间
loadMask:{
msg:"正在加载数据,请稍候......"
},
//行选择模式
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true //只能选择一行,即 单行模式
}),
tbar: [{ //顶部工具条
text: "注册",
tooltip: "注册一个新的用户", //提示信息
iconCls :"houfei-addicon", //图标样式
handler: this.onAddUserInfo, //事件
scope: this
},"-",{
text: "修改",
tooltip: "修改此用户的信息", //提示
iconCls: "houfei-editicon",
handler: this.onEditUserInfo,
scopt: this
},"-",{
text: "刷新",
iconCls: "houfei-refreshIcon",
handler: this.onRefresh,
tooltip: "刷新用户信息",
scope: this
}],
bbar: new Ext.PagingToolbar({
store: this["store"], //数据存储器
pageSize: 17, //页大小
displayMsg: "共<font color=\"green\">{2}</font>条记录,当前页记录索引<font color=\"green\">{0} - {1}</font> ",
displayInfo: true
})
});
this.getStore().load({
params:{
//索引
start: 0,
//页大小
limit: 17
}
});
//alert(this["store"].getCount());
},
/**
* 注册事件
*/
onAddUserInfo: function(){
this.addWin.form.getForm().reset();
this.addWin.show();
},
/**
* 表格数据刷新
*/
onRefresh: function(){
this.getStore().reload();
},
/**
* 修改用户信息
*/
onEditUserInfo: function(){
//获取行选择模版
var _sm = this.getSelectionModel();
//获取当前选择的行数
var _count = _sm.getCount();
//如果用户选择了一行记录
if(_count > 0){
//获取选择的当前记录
var _crr = _sm.getSelected();
//创建一个new record
var _nr = new Ext.data.Record({
"userName": _crr.get("userName"),
"password1": _crr.get("password"),
"password": _crr.get("password"),
"contactTel": _crr.get("contactTel"),
"email": _crr.get("email"),
"creatDate": _crr.get("creatDate")
});
//显示窗体
this.editWin.show();
//加载数据
this.editWin.form.getForm().loadRecord(_nr);
//将pkid传递给editWin对象的editPkId属性
this.editWin.editPkId = _crr.get("userId");
}
else{
Ext.Msg.show({
title: "系统提示",
msg: "请选择一条您要修改的信息",
buttons: Ext.Msg.OK,
icon: Ext.Msg.INFO
});
}
}
});----------------------------------------------
大虾们 帮忙看下我的代码 是怎么回事?我盯了一上午了!
后台的数据在FF的响应里面 能看到从后台取出的数据 但就是在 页面里 显示不出来 是不是 那个属性值没有写,
或写的不对? 而且 也不报错 我用的是 2.3版本 在线等===============================
myid: "my_id",
addWin: null,
editWin: null,
//构造方法
constructor: function(_cfg){
if(_cfg == null){
_cfg = {};
}
Ext.apply(this,_cfg);
//将AddUserInfoWindow的引用赋值给当前属性addWin
//this.addWin = new AddUserInfoWindow();
//this.editWin = new EditUserInfoWindow();
//数据存储器
this["store"] = new Ext.data.JsonStore({
url: 'userInfo.action?method=showInfoByPage',
totalProperty: "totalCount",
root: "rows",
fields: ["userId","userName","password","contactTel","email","creatDate"]
});
//将父类的构造方法Copy过来
UserInfoGridPanel.superclass.constructor.call(this,{
id: this.myid,
title: "用户信息列表",
border: false,
iconCls: "houfei-treeNodeLeafIcon",
stripeRows: true, //交替行效果
viewConfig:{
autoFill: true,
forceFit: true
},
//列模版
colModel: new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),{
header: "编 号",
sortable: true, //允许排序
align:'center',
dataIndex: "userId"
},{
header: "帐 号",
sortable: true, //允许排序
align:'center',
dataIndex: "userName"
},{
header: "密 码",
sortable: true, //允许排序
align:'center',
dataIndex: "password"
},{
header: "手 机 号 码",
sortable: true, //允许排序
align:'center',
dataIndex: "contactTel"
},{
header: "邮 箱",
sortable: true, //允许排序
align:'center',
dataIndex: "email"
},{
header: "创 建 时 间",
sortable: true, //允许排序
align:'center',
dataIndex: "creatDate"
}]),
//填充加载时间
loadMask:{
msg:"正在加载数据,请稍候......"
},
//行选择模式
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true //只能选择一行,即 单行模式
}),
tbar: [{ //顶部工具条
text: "注册",
tooltip: "注册一个新的用户", //提示信息
iconCls :"houfei-addicon", //图标样式
handler: this.onAddUserInfo, //事件
scope: this
},"-",{
text: "修改",
tooltip: "修改此用户的信息", //提示
iconCls: "houfei-editicon",
handler: this.onEditUserInfo,
scopt: this
},"-",{
text: "刷新",
iconCls: "houfei-refreshIcon",
handler: this.onRefresh,
tooltip: "刷新用户信息",
scope: this
}],
bbar: new Ext.PagingToolbar({
store: this["store"], //数据存储器
pageSize: 17, //页大小
displayMsg: "共<font color=\"green\">{2}</font>条记录,当前页记录索引<font color=\"green\">{0} - {1}</font> ",
displayInfo: true
})
});
this.getStore().load({
params:{
//索引
start: 0,
//页大小
limit: 17
}
});
//alert(this["store"].getCount());
},
/**
* 注册事件
*/
onAddUserInfo: function(){
this.addWin.form.getForm().reset();
this.addWin.show();
},
/**
* 表格数据刷新
*/
onRefresh: function(){
this.getStore().reload();
},
/**
* 修改用户信息
*/
onEditUserInfo: function(){
//获取行选择模版
var _sm = this.getSelectionModel();
//获取当前选择的行数
var _count = _sm.getCount();
//如果用户选择了一行记录
if(_count > 0){
//获取选择的当前记录
var _crr = _sm.getSelected();
//创建一个new record
var _nr = new Ext.data.Record({
"userName": _crr.get("userName"),
"password1": _crr.get("password"),
"password": _crr.get("password"),
"contactTel": _crr.get("contactTel"),
"email": _crr.get("email"),
"creatDate": _crr.get("creatDate")
});
//显示窗体
this.editWin.show();
//加载数据
this.editWin.form.getForm().loadRecord(_nr);
//将pkid传递给editWin对象的editPkId属性
this.editWin.editPkId = _crr.get("userId");
}
else{
Ext.Msg.show({
title: "系统提示",
msg: "请选择一条您要修改的信息",
buttons: Ext.Msg.OK,
icon: Ext.Msg.INFO
});
}
}
});----------------------------------------------
大虾们 帮忙看下我的代码 是怎么回事?我盯了一上午了!
后台的数据在FF的响应里面 能看到从后台取出的数据 但就是在 页面里 显示不出来 是不是 那个属性值没有写,
或写的不对? 而且 也不报错 我用的是 2.3版本 在线等===============================
你的json 格式是什么
你现在grid能显示出来吗? 只是没有值?
后台传过来的数据显示:[{"email":"a","userId":1,"userName":"lyl","contactTel":"1212121","createDate":"2011-07-03 00:00:00.0","exist":true,"password":"a"},{"email":"[email protected]","userId":2,"userName":"a","contactTel":"2343434","createDate":"2011-06-19 00:00:00.0","exist":true,"password":"a"},{"email":null,"userId":3,"userName":"b","contactTel":"435435345","createDate":"2011-06-22 00:00:00.0","exist":true,"password":"b"}] gridPanel 能显示出来 就是上面的那个图 现在就是数据显示不出来
scope 那里写错了!汗