AngularJS智能表:如何使用按钮为数据设置预定义的过滤器?

时间:2016-08-09 13:46:38

标签: angularjs smart-table

我正在使用AngularJS的smart-table插件来显示集合信息。我使用stPipe函数将其与我的后端API集成在一起,只要执行searchsort操作就会触发该函数。但是,我想在桌子上方放置一些按钮作为过滤器。当我点击这些按钮中的任何一个时,我想触发智能表的stPipe功能并点击后端API以获取过滤后的结果。我怎么能做到这一点?

1 个答案:

答案 0 :(得分:2)

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

每次调用callServer函数时,它都会更新此变量。这样,您就可以刷新表格。

在此代码中,callServer将是您的stPipe函数,您的外部按钮将调用refreshGrid()函数。

this.tableState = null;

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

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

之前我需要这个,我在这个问题中发布了解决方案:Smart table - angularJs - ajax refresh table