Grid 如何从分页工具栏获取当前页面
我用extjs4.1在我的网格中实现了一个分页工具栏,我得到了20组第一页的记录。但当我单击“下一步”时,它不会显示下一页。我想问题就在这里Grid 如何从分页工具栏获取当前页面,grid,paging,toolbar,extjs4.1,current-page,Grid,Paging,Toolbar,Extjs4.1,Current Page,我用extjs4.1在我的网格中实现了一个分页工具栏,我得到了20组第一页的记录。但当我单击“下一步”时,它不会显示下一页。我想问题就在这里 proxy: { type: 'ajax', scope: this, url: 'Controller/getData', extraParams: { PageNumber: this.currentPage, // this
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'
}
如您所见,我传递给控制器的页码是静态的。。如果我把那页改成任何号码。。。那么,如何获取当前页面,以便将其传递给控制器。。
下面是我的工具栏
bbar: Ext.create('Ext.PagingToolbar', {
scope: this,
store: myStore,
displayInfo: true,
displayMsg: 'Displaying Records {0} - {1} of {2}',
emptyMsg: "No Records to display"
})
请帮忙。。。谢谢我不确定是否能为您提供帮助,您是否检查了后端处理代码?我的意思是,据我所知,您声明存储和分页工具栏的方式是正确的,所以问题可能存在于服务器端 作为参考,这是我的服务器端页面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);
}
});
您确定这一直是您的门店范围吗?是的,sra。。。请看上面我的读者。。而且我还有msg上显示的总记录。。上面说显示100个中的1-20个。。。当我点击next(下一步)时,它会显示21-40和第2页,但网格中有与第1页相同的20个数据。最好至少简要描述一下解决方案的逻辑。嗨,尼克。。。谢谢你的回复。。。我用的是c。。你能用中文解释一下你的服务器端代码吗。。。因为我对php一无所知。。。现在我看到了你的php代码。。。我肯定我有这个问题。。。你能帮我做一下你在PHP上做的事情吗?但是在CI上很抱歉@EagleFox。我不懂C,但我会尝试解释一下我在PHP代码中做了什么$sql=从用户中选择*;将对数据库执行的查询$rs=mysql\u query$sql;执行查询$totalCount=mysql\u num\u rows$rs;获取检索到的记录数$sql=$sql。限额。$start.,.$LIMIT;将页面限制参数添加到查询$rs=mysql\u query$sql;再次执行查询。而$obj=mysql_fetch_object$rs{$arr[]=$obj;}正在抓取记录,然后将其存储在数组中。最后回显“{success:true,totalCount:”.$totalCount.”,data:“.json_encode$arr.}”;将格式设置为JSONTANKS,以便您进行解释,尼克。。。我在那里得到了你在做什么的暗示。。。但在C语言中实现这一点是我遇到的难题