0

我在我的网格中使用 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"
        })

请帮助...谢谢

4

1 回答 1

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);
}
});
于 2012-11-21T02:47:59.190 回答