Closed jdotjdot closed 10 years ago
Hi @jdotjdot ,
So in short, you need to programatically call the select all / select none / reset functions from within your controller? (I'm sorry if I don't quite get it)
Yup--that is one of my use cases, and the one referenced here.
To reiterate, since clearly I didn't explain it very well, I'm using your multiselect in a larger form of various fields that filter a set of data. To offer a "reset all filters" button, I need to programmatically access the .select('none', event)
method of the directive, but since it's not really exposed, I had to do it in the way shown above.
Ah.. loud and clear :)
At the moment there's no method exposing those functionalities, but perhaps, after you create your input model object (say model1), you can create a backup copy of it (say model2), and, when you reset all the filters, you just need to copy model2 back to model1?
I don't think this method is worse than exposing the reset function, since clicking the reset button on my directive is more or less doing the same thing.
That's not a bad idea--but the reason that I can't do that is the amount of data in the input model is so great that I can't afford to have a backup copy of it. It's at the point that I may actually have to switch to JIT paginated loading of the input model data anyway--but at the very least, no room for a backup copy.
On Wed, Aug 13, 2014 at 12:22 AM, Steven notifications@github.com wrote:
Ah.. loud and clear :)
At the moment there's no method exposing those functionalities, but perhaps, after you create your input model object (say model1), you can create a backup copy of it (say model2), and, when you reset all the filters, you just need to copy model2 back to model1?
I don't think this method is worse than exposing the reset function, since clicking the reset button on my directive is more or less doing the same thing.
— Reply to this email directly or view it on GitHub https://github.com/isteven/angular-multi-select/issues/64#issuecomment-52008394 .
I see.. then I guess exposing a function wouldn't help much.. The reset, select all & select none button actually do the same thing.
I'm trying to provide lazy loading and AJAX support for the input for the next release. Perhaps it can help users with a big amount of data.
There's currently no way to programmatically access the select function from outside the directive scope. I'm using the directive as part of a set of filters, and I wanted to add a global reset filter, but setting the
output-model
to empty didn't bind back to the multiselect directive, and I didn't want to destroy and recreate theinput-model
since it has a lot of data and would be very costly.Thus, I ended up declaring the directive with an
id
(<div multi-select id="myid" ....></div>
) and using the following code to reference all of the multiselects and reset them:This is obviously hacky, but this might be avoidable if in the scope declaration, access either to the
select()
function or to some wrappers likeselectNone()
would be offered.