angularjs - 智能表-angularJs-ajax刷新表

标签 angularjs ajax smart-table

我正在使用 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/

相关文章:

javascript - 模块 'smart-table' 不可用

html - 如何防止表格在调整大小时溢出其封闭的 div?

javascript - Angular JS $scope 查询

mysql - AngularJS 指令无法检查 null

javascript - 异步AJAX按顺序调用

ajax - 为什么IE11在ajax请求的请求头中发送 'pragma: no-cache'?

javascript - 在文本输入时动态更新字典

javascript - 在 Angular Bootstrap Modal 和父 Controller 之间共享范围

javascript - 在 View 中迭代 JSON