I'm using smart-table at the moment, and I have input text boxes up the top of each column and I am using st-search. The point of what I am making is something is selected from the table, and then the results in the table are changed.
I am trying to clear the search boxes when the row is clicked. At the moment other business logic is implemented on click, so it's at this point that I am looking to clear these text boxes.
I have tried to associate an ng-model to these text boxes, and to clear them when the row is clicked but the text boxes don't change. I have also googled this issue and I have only found solutions on how to make this work for when you click on a button (by a directive) to clear the predicates. I haven't been able to make these solutions work programatically however.
To resolve this I did the following:
Monkey-patched smarttable.js with the code in this github issue (https://github.com/lorenzofox3/Smart-Table/issues/164). For me this occured at around line 574.
// added from https://github.com/lorenzofox3/Smart-Table/issues/164 ng.module("smart-table").directive("stResetSearch", function() { return { restrict: 'EA', require: '^stTable', link: function(scope, element, attrs, ctrl) { return element.bind('click', function() { return scope.$apply(function() { var tableState; tableState = ctrl.tableState(); tableState.search.predicateObject = {}; tableState.pagination.start = 0; return ctrl.pipe(); }); }); } }; });
Added 'st-research-search' to the element that was calling the function in angularjs. For me, that was the "tr" element. Like below.
This worked fine. Unfortunately, I wasn't able to programatically clear the predicates from the code. But this works well enough for me.