我正在使用 angularjs mudule 智能表。
我的表有服务器端处理,所有数据加载都位于服务器上。我想在表格外面有一个刷新按钮。
这是调用服务器的函数,我希望能够手动调用它,但我不知道如何检索 Controller 中的表状态。
this.callServer = function callServer(tableState) {
ctrl.isLoading = true;
var pagination = tableState.pagination;
var start = pagination.start || 0; // This is NOT the page number, but the index of item in the list that you want to use to display the table.
var number = pagination.number || 10; // Number of entries showed per page.
service.getPage(start, number, tableState, ctrl.startDateFilter,
ctrl.endDateFilter).then(function (result) {
ctrl.displayed = result.data;
tableState.pagination.numberOfPages = result.numberOfPages;
ctrl.isLoading = false;
});
};
我的目标是有一个这样的函数,我怎样才能获取表状态?
this.refreshTable = function(){
tableState = getTableState();
ctrl.callServer(tableState);
}
最佳答案
解决方案是将表状态放入 Controller 变量中。
每次调用callServer函数时,都会更新这个变量。这样,我就可以刷新表格。
this.tableState = null;
this.callServer = function callServer(tableState) {
ctrl.tableState = tableState;
...
}
this.refreshGrid = function(){
ctrl.callServer(ctrl.tableState);
}
关于angularjs - 智能表-angularJs-ajax刷新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38768988/