jQWidgets Forums
jQuery UI Widgets › Forums › Angular › Multi pre Select ComboBox
Tagged: preselect values in combobox
This topic contains 7 replies, has 4 voices, and was last updated by svetoslav_borislavov 2 years, 1 month ago.
-
Author
-
Hi there,
I have been trying to place my data on combo box, which are in combo box source.
My data vales are fetching from server call in ngOnInIt, but here your combo box preselect values functionality is available on ngAfterViewInIt.
Whereas ngAfterViewInIt is called before completion of ngOnInIt in angular. How do i update combo box with later received data?Hi,
Just change the source property of the Combo box and then set the selected index.
Here is an example: http://jsfiddle.net/edh6nts4/
I hope this helps!
Best regards,
Steve PetersonjQWidgets Team
https://www.jqwidgets.com/You didn’t get my requirement. the source has actual or all values as well. I would like to present as pre selected values which are already saved to my data. This call is an editing info of a record which is already saved with some data. I exactly needed like demo of your pre selected values combo box. But it is not happening because of data is not available when ngAfterInIt called. After ngAfterInIt called data getting triggered and received in ngOnInIt. So we cannot stop ng life cycle until data response in ngOnInIt.
The previous response from you has a example is not suits for ng life cycle. Whatever source/ Set combo will show. But data availability on server call is fully dependent on ngOnInIt. ngAfterInIt never wait until ngOnInIt completely has resolved data. We cannot implement pre selected combo box without data.
When i use same combo box with all source in new record selection will work proper.
Find the image to get understand better.
Hi,
Yes, as you said you cannot stop the lifecycle. The call is async which means the data will be received later.
You don’t know when. So the preselection will happen after the data is received. This is not a problem on our side.
A possible solution would be to display some loader until the data is fetchedBest regards,
Svetoslav BorislavovjQWidgets Team
https://www.jqwidgets.com/no loader will not useful for waiting for data. Because only once ngAfterInIt will called whether you have data or not, Loader true or false whatever available values it will get excuted.
You have to make your implementation to suits for ngOnInIt as well, until combo box pre select feature is worthless.Hi rmk3200,
Please see the example here: stackblitz
You can set selection inside of the “loadComplete” function of the dataAdapter. By the time it is called, the combobox will already exist
Best regards,
Ivan Peevski
jQWidgets Team
https://www.jqwidgets.com/my source is one dimensional string array is fetching from server. why work around with data adaptor? can’t show combo box that what i have?
By this i need to change actual source and edit_source as per your reference. and selectIndex is not worked for me.
Can you give me another example of 1D array with strings to preselect the array values on ngOnInIt?Hi,
The dataAdapter is used for its loadComplete method. This way you can select the indexes after the items are loaded.
Another option is with the method onBindingComplete but in setTimeout.
You can have a dataAdapter with an array. https://stackblitz.com/edit/github-7lqwxv-32oawf?file=src/app/app.component.ts
Here is an example with the onBindingComplete: https://stackblitz.com/edit/github-7lqwxv-qgj1sx?file=src/app/app.component.tsBest regards,
Svetoslav BorislavovjQWidgets Team
https://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.