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