我有一个使用extjs 4.1在我的网格中实现的分页工具栏我得到了20组第一页的记录。 “但是”当我点击下一步时,它不会显示下一页。我认为问题在这里
proxy: {
type: 'ajax',
scope: this,
url: 'Controller/getData',
extraParams: {
PageNumber: this.currentPage, // this doesn't change on clicking next
PageSize: 20
},
reader: {
type: 'json',
root: 'myTable',
totalProperty: 'count'
}
正如您所看到的,我传递给控制器的PageNumber是静态的..如果我将其更改为我获得该页面的任何数字...那么如何获取当前页面以便我可以将其传递给我控制器.. 下面是我的工具栏
bbar: Ext.create('Ext.PagingToolbar', {
scope: this,
store: myStore,
displayInfo: true,
displayMsg: 'Displaying Records {0} - {1} of {2}',
emptyMsg: "No Records to display"
})
请帮忙......谢谢
答案 0 :(得分:1)
我不确定我是否可以帮助您,您检查后端处理代码吗?我的意思是,据我所知,你声明存储和分页工具栏的方式是正确的,所以服务器端可能存在问题。
作为参考,这是我的服务器端页面(remote / data / user / mahasiswa / read.php)来处理具有分页支持的商店:
$sql = "SELECT * FROM user";
$rs = mysql_query($sql);
$totalCount = mysql_num_rows($rs);
$sql = $sql." LIMIT ".$start.",".$limit;
$rs = mysql_query($sql);
while($obj = mysql_fetch_object($rs)){
$arr[] = $obj;
}
echo '{success:true, totalCount:'.$totalCount.', data:'.json_encode($arr).'}';
然后,这是我的商店:
Ext.define('PMK.store.user.Mahasiswa', {
extend: 'Ext.data.Store',
model: 'PMK.model.user.Mahasiswa',
pageSize: 30,
proxy: {
type: 'ajax',
url: 'remote/data/user/mahasiswa/read.php',
reader: {
type: 'json',
root: 'data',
successProperty: 'success',
totalProperty: 'totalCount'
}
})
最后这是我的观点:
Ext.define('PMK.view.user.mahasiswa.List' ,{
extend: 'Ext.panel.Panel',
alias : 'widget.mhslist',
title:'Manage Mahasiswa',
layout:'fit',
initComponent: function() {
this.items = [
{
xtype:'grid',
store:'user.Mahasiswa',
columns: [
{xtype: 'rownumberer', width: 50, sortable: false},
{header: 'Angkatan', dataIndex: 'ANGKATAN', sortable:true, width:60},
{header: 'NIM', dataIndex: 'NIM', sortable:true, width:100},
{header: 'Nama', dataIndex: 'NAMA', sortable:true, width:225},
{header: 'Program Studi', dataIndex: 'PRODI', sortable:true, width:225},
{header: 'Kelas', dataIndex: 'KELAS', sortable:true, width:50},
{header: 'Dosen PA', dataIndex: 'DOSEN_PA', sortable:true, width:125},
{header: 'Jalur', dataIndex: 'JALUR', sortable:true, width:50},
{header: 'Asal Sekolah', dataIndex: 'ASAL_SEKOLAH', sortable:true, width:175},
{header: 'Tempat Lahir', dataIndex: 'TL', sortable:true, width:100},
{header: 'Tanggal Lahir', dataIndex: 'TGL', sortable:true, width:75},
{header: 'JK', dataIndex: 'JK', sortable:true, width:25},
{header: 'Alamat', dataIndex: 'ALAMAT', sortable:true, width:225},
{header: 'Email', dataIndex: 'EMAIL', sortable:true, width:130},
{header: 'Telp', dataIndex: 'TELP', sortable:true, width:100},
{header: 'Agama', dataIndex: 'AGAMA', sortable:true, width:50},
{header: 'Input Date', dataIndex: 'INPUT_DATE', sortable:true, width:125},
{header: 'Input By', dataIndex: 'INPUT_BY', sortable:true, width:125},
{header: 'Edit Date', dataIndex: 'EDIT_DATE', sortable:true, width:125},
{header: 'Edit By', dataIndex: 'EDIT_BY', sortable:true, width:125}
]
}
];
this.bbar = Ext.create('Ext.PagingToolbar', {
store: 'user.Mahasiswa',
displayInfo: true,
displayMsg: 'Displaying mahasiswa {0} - {1} of {2}',
emptyMsg: "No mahasiswa to display"
});
this.callParent(arguments);
}
});