Ext gird分页学习

var store = new Ext.data.Store({
// 使用一个URL获取数据源
url: '../ListAlarminfoAfterten.form',

//映射关系
reader: new Ext.data.XmlReader({
record: 'tbalarminfo',
id: 'id',
totalRecords:'countRow'
}, [
{name: 'id', mapping: 'ItemAttributes > id'},
'id','errorid','taskname','alarmtime','descr','matter','rating','status'
])
});
//创建一个表格对象
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),//自动行号
sm,//添加的地方
{header: "id", dataIndex: 'id',hidden:true},
{header: "错误ID", width: 100, dataIndex: 'errorid'},
{header: "任务名称", width: 100, dataIndex: 'taskname'},
{header: "时间", width: 100, dataIndex: 'alarmtime'},
{header: "报警描述", width: 150, dataIndex: 'descr'},
{header: "错误内容", width: 150, dataIndex: 'matter',hidden:true},
{header: "级别", width: 100, dataIndex: 'rating'},
{header: "状态", width: 100, dataIndex: 'status',renderer:function(value){
if (value == '0') {
return "未通知";
} else if (value == '1') {
return "未处理";
}else if (value == '10') {
return "已处理";
}
}}
]);
cm.defaultSortable = true;

// create the grid
var grid = new Ext.grid.GridPanel({
el:'example-grid',
store: store,
cm: cm,
sm: sm,
width: 700,
height: 310,
fitToFrame: true,
title:'文件同步历史报警信息列表',
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: store,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});

grid.render();
store.load({ params : { start : 0, limit : 10 }});

//为grid添加双击事件做弹出窗口处理

grid.addListener('rowdblclick',function(){

var records = grid.getSelectionModel().getSelections();
var stat = records[0].get("status");
id=records[0].get('id');
errorid=records[0].get('errorid');
errordescr=records[0].get('descr');
matter=records[0].get('matter');
if(stat!="10"){
if(!records.length){
alert("请选择要处理的报警信息");
}
else{

window.open ('ModifyFileAlarmStatById.jsp?id='+id+","+errorid+","+errordescr+","+matter,'newwindow', 'height=300, width=540, top=200, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}
}else{
window.open ('ViewAlarmDisposenoticeById.jsp?id='+id+","+errorid+","+errordescr+","+matter,'newwindow', 'height=200, width=540, top=200, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}
});


xml 结合 extajax 分页 以及grid 添加监听方法处理操作
后台 java 获得 start的起始条数
数据库写 sql 查询相应的第几条到多少条数的数据

你可能感兴趣的:(ExtJs)