PagingGridPanel =Ext.extend(Ext.grid.GridPanel,{
constructor:function(){
this["store"]:new Ext.data.Store({
url:"",
//reader解析
reader:new Ext.data.XmlReader({
autoLoad:true,
record:"row",//解析指定xml的节点
//分页需要的属性(数量)
totalRecords:"@count"
},Ext.data.Record.create([{//对应XML的字段
name:"id" ,mapping:"@id"
},{
name:"type" ,mapping:"@type"
},{
name:"money",mapping:"@money"
}])
)
});
PagingGridPanel.superclass.constructor.call(this,{
renderTo:Ext.getBody(),
width:300,
height:400,
//baseParams:{start:0,limit:5}
//可以选择行数
sm:new Ext.grid.RowSelectionModel({
//设置为单选
singleSelect:true
}
bbar:new Ext.PagingToolbar({
store:this.store,
//一页显示多少个
pageSize:5
}),
//绑定store中的数据到列中
columns:[{
header:"类型",
dataIndex:"type"
},{
header:"金额",
dataIndex:"money"
}]
});
/*
this.getStore().on("load",function(_store){
//_store.getTotalCount()中值的数量
alert(_store.getTotalCount());
});*/
this.getStore().load({params:{start:0,limit:5}});
}
});
10-13
10-13