智能表-angularJs-Ajax刷新表 [英] Smart table - angularJs - ajax refresh table

查看:49
本文介绍了智能表-angularJs-Ajax刷新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用angularjs混搭智能表.

I am using the angularjs mudule smart table.

我的表具有服务器端处理,所有数据加载都位于服务器上.我想在桌子外面有一个刷新按钮.

My table has server-side processing and all the data load is located on the server. I want to have a refresh button outside of the table.

这是一个调用服务器的函数,我希望能够手动调用它,但是我不知道如何在控制器中检索表状态.

This is the function that makes a call to the server and I want to be able to call it manually, but I can't figure out how to retrieve the table state in the my 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;
        });
    };

我的目标是拥有这样的功能,如何获取表状态?

My goal is to have a function like this, How can I get the table state?

    this.refreshTable = function(){
        tableState = getTableState();
        ctrl.callServer(tableState);
    }

推荐答案

解决方案是将表状态放入控制器变量中.

The solution is to put the table state in a controller variable.

每次调用callServer函数时,它将更新此变量.这样,我就可以刷新表.

Everytime the callServer function is called, it will update this variable. This way, I am able to refresh the table.

    this.tableState = null;

    this.callServer = function callServer(tableState) {
        ctrl.tableState = tableState;
        ...
    }

    this.refreshGrid = function(){
        ctrl.callServer(ctrl.tableState);
    }

这篇关于智能表-angularJs-Ajax刷新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆