Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async List for Autocomplete list #355

Closed
ashamnx opened this issue May 10, 2017 · 5 comments
Closed

Async List for Autocomplete list #355

ashamnx opened this issue May 10, 2017 · 5 comments

Comments

@ashamnx
Copy link

ashamnx commented May 10, 2017

Is there a way i can load a list of autocomplete options directly in the model? Or is building the model after loading the list the only way ?

@udos86
Copy link
Owner

udos86 commented May 11, 2017

@ashamnx No sorry, at the moment you cannot apply some kind of Observable to list property. However you should be able to just update the list property of your model after loading the autocomplete entries.

@ashamnx
Copy link
Author

ashamnx commented Jun 1, 2017

I have managed to set the list . however Im unable to set the list with id-ed items. is it possible to have name displayed while id is set as the value?

@udos86
Copy link
Owner

udos86 commented Jun 2, 2017

Sorry, list currently only accepts a simple Array<string> following HTML datalist tag

@sarora2073
Copy link

sarora2073 commented Nov 14, 2017

fyi - i created a fork here https://github.com/sarora2073/ng-dynamic-forms which allows support for object arrays to be bound to the autocomplete, not just list data.

I'm glad to do a PR but defer to @udos86 on whether such a breaking change should be introduced, or if there is better way to introduce this.

If incorporated, the breaking change would no longer allow the 'list' field alone on the DynamicInputModel. Instead, the DynamicInputModel would require a 'dataType' field to be provided as well, to indicate whether the data is of list or object array, for this change to work.

Here's an example of the two types of supported models:

            new DynamicInputModel({ 
                id: 'phoneType', 
                placeholder: 'Phone Type', 
                dataType: 'list', 
                list: ['Home', 'Work'] 
            })

            new DynamicInputModel({ 
                id: 'phoneType', 
                placeholder: 'Phone Type', 
                dataType: 'objectArray', 
                objectArray: [{value: 'home', label: 'Home'}, {value: 'work', label: 'Work'}],
            })

Feedback appreciated.

Thanks.

-S. Arora

Note: the material2 [displayWith] directive is not yet supported but i'm looking into options for that pending feedback from the material2 team.

@PaulD1980
Copy link

PaulD1980 commented Aug 7, 2018

@sarora2073 - Can you help me with 830 ?
Description - It would be great if there is two more method/function in the DynamicFormService which can set the values of the controls from the JSON object or TypeScript object and other to get it .

For example

DynamiFormService.getCurrentFormValues(); returns the jsonObject
DynamicFormService.setCurrentFormValues(jsonObject); pass the jsonObject

This jsonObject should map exactly same as form model. Once user gets the object, he can do the rest of the processing as per requirement. Every use-case needs such functionality and setting individual controls values is kinda duplicating the effort in every use-case. It will cover 80% of use-cases where it can be used without any hassle .For other complex scenarios- developers can still use as they are using it by iterating and setting values/reading values from them.

@udos86 udos86 closed this as completed in 2f98d9e Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants