如何使用 dojo/Javascript 在 dgrid 中发送页面更改通知
how to send notification on page change in dgrid using dojo/Javascript
我正在使用带分页的 dgrid,我必须向用户发送通知,告知他当前正在查看 dgrid 的哪个页面。
libraries used for dgrid/Pagination:
"dgrid/OnDemandGrid",
"dgrid/Selection",
"dgrid/extensions/Pagination"
dgrid creation:
var CustomGrid = declare([Grid, Selection, Pagination]);
this.grid = new CustomGrid({
columns: columns,
collection: new Memory({ data: [] }),
selectionMode: "toggle",
keepScrollPosition: true,
noDataMessage: this.sharedNls.errorMessages.invalidSearch,
pagingLinks: true,
pagingTextBox: true,
firstLastArrows: true,
minRowsPerPage: 5,
rowsPerPage: 100
}, this.gridContainer);
this.grid.startup();
Attaching events:
on(this.grid, "(dgridPageChangeEventName)", lang.hitch(this, function (page) {
// send notification code will be added here
alert( "You are looking at page no " + page);
}));
Issue:
按照上面的代码我需要页面更改事件名称或变通,以便我可以在那里编写自定义代码以向用户发送通知。
谢谢!
没有为此发出特定的事件,因为通常这已经可以通过 gotoPage
用于切换页面的方法之后的方面检测到:
aspect.after(this.grid, 'gotoPage', function (promise, args) {
// promise is the promise returned from the original gotoPage
// args are the original arguments passed, so args[0] is the requested page #
promise.then(function () {
console.log('Now viewing page ' + args[0]);
});
return promise;
});
PS:您不应该在同一个网格中同时使用 OnDemandGrid 和 Pagination,as mentioned in the documentation。直接将Pagination混合到Grid中。
我正在使用带分页的 dgrid,我必须向用户发送通知,告知他当前正在查看 dgrid 的哪个页面。
libraries used for dgrid/Pagination:
"dgrid/OnDemandGrid",
"dgrid/Selection",
"dgrid/extensions/Pagination"
dgrid creation:
var CustomGrid = declare([Grid, Selection, Pagination]);
this.grid = new CustomGrid({
columns: columns,
collection: new Memory({ data: [] }),
selectionMode: "toggle",
keepScrollPosition: true,
noDataMessage: this.sharedNls.errorMessages.invalidSearch,
pagingLinks: true,
pagingTextBox: true,
firstLastArrows: true,
minRowsPerPage: 5,
rowsPerPage: 100
}, this.gridContainer);
this.grid.startup();
Attaching events:
on(this.grid, "(dgridPageChangeEventName)", lang.hitch(this, function (page) {
// send notification code will be added here
alert( "You are looking at page no " + page);
}));
Issue:
按照上面的代码我需要页面更改事件名称或变通,以便我可以在那里编写自定义代码以向用户发送通知。
谢谢!
没有为此发出特定的事件,因为通常这已经可以通过 gotoPage
用于切换页面的方法之后的方面检测到:
aspect.after(this.grid, 'gotoPage', function (promise, args) {
// promise is the promise returned from the original gotoPage
// args are the original arguments passed, so args[0] is the requested page #
promise.then(function () {
console.log('Now viewing page ' + args[0]);
});
return promise;
});
PS:您不应该在同一个网格中同时使用 OnDemandGrid 和 Pagination,as mentioned in the documentation。直接将Pagination混合到Grid中。