简体   繁体   English

ExtJS分页工具栏开始页面

[英]ExtJS Paging Toolbar start page

I have an ExtJS GridPanel with a store and a paging toolbar at the bottom. 我有一个ExtJS GridPanel,在底部有一个商店和一个分页工具栏。 I can manually set the start page through the browser using: 我可以使用以下方法通过浏览器手动设置起始页:

www.someurl.com/page/7

This will load the data store with page 7 correctly. 这将正确加载第7页的数据存储。 However, the paging toolbar does not update the page number from the store (it still shows 1). 但是,分页工具栏不会更新商店中的页码(仍然显示1)。 I was under the impression that by changing the page of the store also changes the page in the paging toolbar, but this is not the case. 我的印象是,通过更改商店的页面也会更改分页工具栏中的页面,但事实并非如此。 Here is some example code: 这是一些示例代码:

var _store = new Ext.data.Store({
  id          : 'store_id',
  remoteSort  : true,
  autoDestroy : true,
  restful     : true,
  proxy       : _proxy,
  reader      : _reader,
  writer      : _writer
});

var _pagingToolbar = new Ext.PagingToolbar({
  displayInfo    : true,
  pageSize       : 20,
  store          : _store
});

_I.grid = new Ext.ux.GridPanel({
 id             : _I.options.id+'_grid',
 title          : _I.options.title,
 store          : _store,
 bbar        : _pagingToolbar
});


_I.options.page = 7; //start store on page 7

_I.grid.render('somediv');
_store.load({params:{start:_I.options.page, limit:20, sort:'id', dir:'ASC'}});

Since the start page is set to 7, the data that loads in the store is correct, however, the page in the paging toolbar reads 2. I have tried manually setting the page with 由于起始页面设置为7,因此存储在商店中的数据是正确的,但是,分页工具栏中的页面显示为2。

_pagingToolbar.changePage(20); // should set page to 20

I get the same result, the data store loads up the correct page, however the toolbar text does not change. 我得到相同的结果,数据存储区加载正确的页面,但是工具栏文本未更改。 Is the order wrong? 顺序错了吗? I also tried loading the store before the grid is rendered, to no avail, with same result. 我还尝试在渲染网格之前加载商店,但没有结果,结果相同。

As the store and the paging bar are inhernatly linked, you should simply be able to use the .changePage(n) method to change the page and automatically adjust the content of the store. 由于商店和分页栏是固有链接的,因此您只需使用.changePage(n)方法即可更改页面并自动调整商店的内容。 You shouldnt need to also code the store with a recordset update. 您也不需要使用记录集更新对商店进行编码。 Also, are you 100% sure the store is displaying the correct records for page '7'? 另外,您是否100%确定商店显示的页面“ 7”的正确记录?

What pagination info are you returning from the server side? 您要从服务器端返回哪些分页信息? PagingToolbar just takes that info from the store. PagingToolbar只是从商店获取该信息。

Could you please show your reader and the part of server response showing pagination data? 您能否显示您的阅读器以及显示分页数据的服务器响应部分?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM