将pagin工具栏动态添加到网格Ext-JS 4时,分页不起作用

时间:2013-01-09 10:29:47

标签: extjs extjs4

在我的应用中,一切都应该是动态的。我正在创建一个这样的视图:

this.store = Ext.create('Test.store.Users');
this.model = Ext.ModelManager.getModel(this.store.model);
this.view = Ext.create('Test.view.Users.Index');
this.view.init();

Ext.create视图创建一个网格,init函数创建一个分页工具栏:

init: function(){

var pToolbar =  new Ext.PagingToolbar({
        dock: 'bottom',
        store: this.store,
        displayInfo: true
});

this.addDocked([pToolbar]);

}

this.store有正确的参考(检查过),刷新效果很好,但分页不!我总是得到所有结果,而不是分页。我在init()中尝试过类似的东西:

//bind a store to a toolbar
pToolbar.bindStore(this.store);
//reconfigure grid
this.reconfigure(this.store);
//load just the first page
this.store.loadPage(1);

同样的事情。我得到了所有240条记录,而不是25条记录。

谢谢。

1 个答案:

答案 0 :(得分:0)

加载商店时,您必须传递startlimit个参数。在商店配置或集合中提及pageSize也是动态的。您可以加载像

这样的商店
store.load({
    params:{
        start:0,
        limit: itemsPerPage
    }
});

如果您是从服务器接收数据,那么在服务器端,您必须根据selectstart参数构建limit查询。