Reputation: 8224
I am using smart-table
plugin for AngularJS to display a collection information. I have integrated the same with my backend API using the stPipe
function which is triggered whenever a search
or sort
operation is performed. However, I want to place some buttons above the table which act as a filter. When I click on either of these buttons, I want to trigger the stPipe
function of smart table and hit the backend API to fetch the filtered results. How can I accomplish this ?
Upvotes: 0
Views: 443
Reputation: 546
The solution is to put the table state in a controller variable.
Everytime the callServer function is called, it will update this variable. This way, you will be able to refresh the table.
In this code, the callServer would be your stPipe function and your external button would call the refreshGrid() function.
this.tableState = null;
this.callServer = function callServer(tableState) {
ctrl.tableState = tableState;
...
}
this.refreshGrid = function(){
ctrl.callServer(ctrl.tableState);
}
I needed this before and I have posted the solution in this question: Smart table - angularJs - ajax refresh table
Upvotes: 2