Extjs GridPanl可以读取到数据,但无法显示列表? 15
源码:Ext.onReady(function(){Ext.QuickTips.init();varsm=newExt.grid.CheckboxSelectionMod...
源码:
Ext.onReady(function() {
Ext.QuickTips.init();
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
sm,
{header : "学员姓名",dataIndex:"sname",align:"center"},
{header : "学员身份证号码",dataIndex:"slicence",align:'center'},
{header : "学员编号",dataIndex:"sno",align:'center'},
{header : "性别",dataIndex:"ssex",align:'center'},
{header : "联系电话",dataIndex:"stelephone",align:'center'},
{header : "使用状态",dataIndex:"StateId",align:'center'},
{header : "班级",dataIndex:"ClassName",align:'center'}
]);
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'service.aspx?MothedType=studentlist'}),
root: 'data',
reader : new Ext.data.JsonReader({
totalProperty: 'totalCount',
successProperty :'success',
root: 'data',
fields:[
{name: 'sname'},
{name: 'slicence'},
{name: 'sno'},
{name: 'ssex'},
{name: 'stelephone'},
{name: 'StateId'},
{name: 'ClassName'}
]
}),
listeners: {
load: function(ds, rs) {
alert (ds.getCount());
}
}
});
//el:指定html元素用于显示grid
//grid.render();//渲染表格
ds.load({params:{start:0, limit:5}});
var gp = new Ext.grid.GridPanel({
cm : cm,
ds : ds,
sm : sm,
width:'auto',
height:'720px',
viewConfig: {forceFit:true}, //自动分配列宽
bbar: new Ext.PagingToolbar({
store: ds,
pageSize:5,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
var PnlStu=new Ext.Panel({
renderTo:Ext.getBody(),
title:'学员管理',
items:[gp]
});
gp.render();
PnlStu.render();
ds.each(function(record){
var newData = jsonData.data[record.id];
record.set(dataIndex,newData.SuccessCount);
record.commit();
});
});
结果: 展开
Ext.onReady(function() {
Ext.QuickTips.init();
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
sm,
{header : "学员姓名",dataIndex:"sname",align:"center"},
{header : "学员身份证号码",dataIndex:"slicence",align:'center'},
{header : "学员编号",dataIndex:"sno",align:'center'},
{header : "性别",dataIndex:"ssex",align:'center'},
{header : "联系电话",dataIndex:"stelephone",align:'center'},
{header : "使用状态",dataIndex:"StateId",align:'center'},
{header : "班级",dataIndex:"ClassName",align:'center'}
]);
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'service.aspx?MothedType=studentlist'}),
root: 'data',
reader : new Ext.data.JsonReader({
totalProperty: 'totalCount',
successProperty :'success',
root: 'data',
fields:[
{name: 'sname'},
{name: 'slicence'},
{name: 'sno'},
{name: 'ssex'},
{name: 'stelephone'},
{name: 'StateId'},
{name: 'ClassName'}
]
}),
listeners: {
load: function(ds, rs) {
alert (ds.getCount());
}
}
});
//el:指定html元素用于显示grid
//grid.render();//渲染表格
ds.load({params:{start:0, limit:5}});
var gp = new Ext.grid.GridPanel({
cm : cm,
ds : ds,
sm : sm,
width:'auto',
height:'720px',
viewConfig: {forceFit:true}, //自动分配列宽
bbar: new Ext.PagingToolbar({
store: ds,
pageSize:5,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
var PnlStu=new Ext.Panel({
renderTo:Ext.getBody(),
title:'学员管理',
items:[gp]
});
gp.render();
PnlStu.render();
ds.each(function(record){
var newData = jsonData.data[record.id];
record.set(dataIndex,newData.SuccessCount);
record.commit();
});
});
结果: 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询