isteven / angular-multi-select

A multi select dropdown directive for AngularJS. Allows you to use HTML tags and CSS in the data. Requires only AngularJS and nothing else.
isteven.github.io/angular-multi-select
MIT License
1.08k stars 518 forks source link

Select within grouping variable #482

Closed rafiko1 closed 8 years ago

rafiko1 commented 8 years ago

Hi,

My data is alike the following format (hypothetically): I have a variable CustomerName (names ID of every customer), and every customer has a particular food that he likes saved under variable FoodName (can be for example pizza, spaghetti, tiramisu or whatever).

I ask my customer what are is most favorite food among those that he likes and that's what I want to select. For example Customer1: likes only pizza so I can select that because that's the only food he named. Customer2: likes spaghetti & tiramisu but his favorite is tiramisu so I want to select that.

And so on...

Is this kind of grouping possible to obtain with the angular-multi-select? I want to save both the CustomerName as the FoodName that I chose (Customer1 - pizza, Customer2 - tiramisu, etc.)

isteven commented 8 years ago

@rafiko1 ,

Disclaimer: I'm not sure I totally understand your situation..

However, since the grouping is basically a flat array, I can say that as long as you try to format your array like what the grouping feature needs, it should be possible.

In short; the input array for grouping is like..

[0]: GROUP ITEM 1: START [1]: ITEM 1.1 [2]: ITEM 1.2 [3]: ITEM 1.3 [4]: GROUP ITEM 1: END [5]: GROUP ITEM 2: START [6]: ITEM 2.1 [7]: ITEM 2.2

[X]: GROUP ITEM 2: END

rafiko1 commented 8 years ago

@isteven

I understand how the grouping works the way u described it. I'll probably have to do some formatting to my array.

My question is if it's possible: 1) To automatise this process of grouping when you always get different groups. One time it's GROUP ITEM 1, GROUP ITEM 2 - and another time it's GROUP ITEM 1, GROUP ITEM 2, GROUP ITEM 3. 2) To save the Group Item together with the chosen Item (now only Item is saved).

isteven commented 8 years ago

@rafiko1 ,

The directive is unable to do such automatic formatting. You are correct that, you need to format the array of object instead in your controller & pass it into the directive.

Saving is basically looping on the array of objects & manually detect the selected group items (or whichever item you need to save). Again, in your case, you most likely need to do a more specific saving function.

rafiko1 commented 8 years ago

@isteven Okay tnx for the help.