我正在为 IBM BusinessSpace 创建小部件,但在分页时遇到了一些困难。数据从数据库成功返回(使用restlet)并显示在网格中。导航也显示在网格下方(下一页、上一页、转到页面、页数等)。例如,如果我有 3 页,每页 5 行,并且想要导航到第二页,当我单击第 2 页时,数据重新加载(似乎再次调用了 restlet),前 5 行(显示在第一页上)也显示在这个页面上。如果我选择任何其他导航选项(下一页,...),也会发生同样的事情。最重要的是,每次点击都会从我的数据库中产生前 5 行。有关如何解决此问题的任何线索?
这是有关此的代码:
dojo.require("dojo.data.ObjectStore");
dojo.require("dojox.grid.enhanced.plugins.Pagination");
dojo.require("dojox.grid.EnhancedGrid");
dojo.require("dojo.store.JsonRest");
var restStore = new dojo.store.JsonRest({target:"https://localhost:9443/Application/hello"});
var dataStore = dojo.data.ObjectStore({objectStore: restStore});
dojo.ready(function(){
var grid = new dojox.grid.EnhancedGrid({
store: dataStore, <br>
structure: [
{name:"Value", field:"value", width: "auto"},
{name:"RequestID", field:"requestId", width: "auto"},
{name:"ID", field:"id", width: "auto"},
{name:"Name", field:"name", width: "auto"}
],
columnReordering: true,
clientSort: true,
rowSelector: '20px',
rowsPerPage: 5,
autoHeight: true,
plugins: {
pagination: {
pageSizes: ["5", "10", "15", "All"], // page length menu options
description: true, // display the current position
sizeSwitch: true, // display the page length menu
pageStepper: true, // display the page navigation choices
gotoButton: true, // go to page button
position: "bottom" // position of the pagination bar
}
}
}, "gridDiv");
grid.startup();
});