Camillia
asked on
Angular - example works but want to make a change to it
I have some controls like 2 dropdowns, a text box. Next to each, there's a button. User clicks the button and the corresponding control gets cleared. Also..the angular table gets reset.
I found this example that works but when I click on one button...All the controls on the page get reset. Grid gets reset to previous state which is correct.
Scroll down to middle of it. The solution by BobKurtis
https://github.com/lorenzofox3/Smart-Table/issues/164
This is my 2 controls
And a ddl
That st-reset-search doesn't take a specific control.
This one does it per individual control but I couldn't get it working.
https://github.com/lorenzofox3/Smart-Table/issues/208
How can I change the first example and do it per control?
I found this example that works but when I click on one button...All the controls on the page get reset. Grid gets reset to previous state which is correct.
Scroll down to middle of it. The solution by BobKurtis
https://github.com/lorenzofox3/Smart-Table/issues/164
This is my 2 controls
<input type="text" st-search="type" />
<button class="..." st-reset-search> clear textbox </button>
And a ddl
<select ng-model="something">
<option ....
</select>
<button class="..." st-reset-search> clear textbox </button>
That st-reset-search doesn't take a specific control.
This one does it per individual control but I couldn't get it working.
https://github.com/lorenzofox3/Smart-Table/issues/208
How can I change the first example and do it per control?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No I mean write your own directive.
ASKER
Ah. Don't know how to do it. The second link I posted should do it but I get a syntax error. I'll start from there.
I thought there's a way to change the first one I posted and change it to do the clear per control.
I'll use these as examples and go from there.
I thought there's a way to change the first one I posted and change it to do the clear per control.
I'll use these as examples and go from there.
I thought there's a way to change the first one I posted and change it to do the clear per control.
There probably is but it would involve changing the directive - which is effectively authoring your own - as the new one will be distinct from the one it is derived from.
ASKER
Ok, thanks. I'll start with the second one. I put some console.logs in there to understand the code first.
I'll look into refreshing/resetting the grid as well. This was my initial issue that I came across when using ng-click to get this done.
I'll look into refreshing/resetting the grid as well. This was my initial issue that I came across when using ng-click to get this done.
ASKER
I put console.log and have a better understanding of what the directive does. I see the scope and values and the table state, etc.
I figured out how to pass the parameter like your example below.
st-reset-search="name-of-c ontrol-to- reset"
I'll continue and if I can't figure out the rest, I'll open another question.
I like jquery better :)
I figured out how to pass the parameter like your example below.
st-reset-search="name-of-c
I'll continue and if I can't figure out the rest, I'll open another question.
I like jquery better :)
ASKER
I got it ! I'll post the solution here just in case someone else is looking for a solution.
Awesome! Well done.
ASKER
I tried ng-click. Wrote a function. Cleared the text box but don't know how to refresh the grid. That's why I found that directive.
I'll see what else I can do.