matsura / ng2-dual-list-box

A dual list box component for Angular 4
http://ng2-duallistbox-demo.surge.sh/
28 stars 20 forks source link

Bind to string values #3

Closed martinobordin closed 7 years ago

martinobordin commented 7 years ago

Hi @matsura, sorry to bother you. Is it possibile to bind to a simple array of strings instead of an objects?

I explain better. I have a list of objects that I use to fill the listbox, using [data] property and formControlName (thanks for your recent fix).

The selection works fine, but instead of an array of objects I would like to have as result an array of strings:

e.g: I would like to have this["Customer1", "Customer"]instead of [{ "value": "Customer1", "text": "Customer1" }, { "value": "Customer2", "text": "Customer2" }]

Is it possible?

matsura commented 7 years ago

@martinobordin You are right, I should have returned only values. I will do this soon(tomorrow probably). I will close and comment once it is done.

martinobordin commented 7 years ago

Ok thank you very much @matsura . I've got other suggestion (not prioritary though):

Thanks a lot for your component

matsura commented 7 years ago

@martinobordin I have implemented ngModel and formControlName to contain array of values. If you have a need for objects you can get the from outputs on the component. I am very thankful for testing my component and giving me suggestions. If you can, make a new issue for each suggestion and put label 'enhancement' on it. I will implement both of these, but I need more details for the second one(expose the text).

Thank you very much!

martinobordin commented 7 years ago

@matsura I created the two issues. Sorry but I didn't understand well what you mean. I could I get in the formControlName only the array of strings instead of objects?

matsura commented 7 years ago

@martinobordin Yes, formcontrolname or ngmodel now give you an array of values.

martinobordin commented 7 years ago

@matsura Hi, when I select the items now I get the array of values, great. However it doesn't preselect the items.

Scenario: I've got an array of available items (100 elements) and an array of preselected items (15 elements) . Expected: It should shows in the "Available items" listbox the former array and in the "Selected items" array the latter. Actual: It only shows "Available items" listbox, the "Selected items" listbox is empty.

matsura commented 7 years ago

@martinobordin It will be fixed later today. Thanks for patience.

matsura commented 7 years ago

@martinobordin Preselection is now possible. You have to pass an array of values.

martinobordin commented 7 years ago

Now it's perfect..thanks you very much for the great (and quick) improvements

martinobordin commented 7 years ago

@matsura There are some debugger left in the code..if you could remove them in the next release..thanks

matsura commented 7 years ago

@martinobordin Debugger removed, sorry about that.

rakesh00005 commented 6 years ago

@martinobordin Can you help me how to populate values in selected Items listbox? I have tried with ngmodel , but no luck. It will be very helpful if you provide an example.

martinobordin commented 6 years ago

Can You prepare a sample on stackblitz?

Il mar 25 set 2018, 21:56 rakesh00005 notifications@github.com ha scritto:

@martinobordin https://github.com/martinobordin Can you help me how to populate values in selected Items listbox? I have tried with ngmodel , but no luck. It will be very helpful if you provide an example.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/matsura/ng2-dual-list-box/issues/3#issuecomment-424479808, or mute the thread https://github.com/notifications/unsubscribe-auth/ABrn2MIdnKDI9cxwlfSICKVFs7KazO7zks5ueopigaJpZM4OZY5V .