Selection Dropdown values dynamically. | Community
Skip to main content
Mani_kumar_
New Participant
Mar 14, 2016 3:21 PM UTC
Solved

Selection Dropdown values dynamically.

Hi All,

We have requirement where we need configure the pagepath in dialog and display list of component names in selection dropdown.

attaching screenshot.

Thanks,

Mani Kumar K

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Mani_kumar_
Mani_kumar_Accepted solution
New Participant
Mar 15, 2016 1:46 PM UTC

Hi All,

Got the solution please find below code snippet

function(){ 
var dialog = this.findParentByType('dialog');
var selectBox = dialog.findByType('selection')[0];
        $.getJSON('/libs/dropdown?Path=' + this.value, 
            function(jsonData){
                        selectBox.setOptions(jsonData);
                        });
 }

11 replies

vidyab9364493
New Participant
Jan 23, 2019 12:00 PM UTC

Hi Mani,

Same doesn't seem to work for 2 dropdowns, any idea how to make it work for dynamic dropdowns

Regards,

Vidya AV

Translate
Level 2
Jul 11, 2017 6:34 AM UTC

Hi,

I have a similar question.
I have 2 dropdowns and i need selectionchanged event to populate the values of the 2nd dropdown.

I was fetching both dropdown values from a servlet whose path i am giving in options property. I later tried using the listener to populate the values for the 2nd dropdown. 1st dropdown still uses the options property.

Please refer the link below, the usecase is explained here:

https://forums.adobe.com/message/9688569#9688569

I have also tried with the solution provided in this thread but its not working:

function(){

var dialog = this.findParentByType('dialog');

var selectBox = dialog.findByType('selection')[1];   /*what i understood is that it is the index of the selection widget so i gave 1 which                                                                                      means 2nd selection node i.e city in my case */

        $.getJSON('/bin/dialog/states?name=' + this.value,

            function(jsonData){

                        selectBox.setOptions(jsonData);

                        });

}

Please suggest the changes.

edubey​

Manikumar​

Translate
edubey
Level 10
Mar 15, 2016 1:50 PM UTC

Great!!...

Translate
Mani_kumar_
Mani_kumar_AuthorAccepted solution
New Participant
Mar 15, 2016 1:46 PM UTC

Hi All,

Got the solution please find below code snippet

function(){ 
var dialog = this.findParentByType('dialog');
var selectBox = dialog.findByType('selection')[0];
        $.getJSON('/libs/dropdown?Path=' + this.value, 
            function(jsonData){
                        selectBox.setOptions(jsonData);
                        });
 }

Translate
edubey
Level 10
Mar 15, 2016 1:34 PM UTC

Whatever you are doing here 

function(){ var servletPath = '/libs/dropdown?Path=$PATH';
return CQ.Util.eval(servletPath); }

will be done by function called by listener

Add a dialogClose listener on your pathfield. with value a function A(). When ever you will close dialog of pathfield. function A() will get called.

In function A() you will write above code.

make sure in function A(), once you have created the array from servlet data do not return array , rather set that array as a value for optionProvider

Translate
Mani_kumar_
New Participant
Mar 15, 2016 12:19 PM UTC

edubey wrote...

1. In listener you will make call to your servlet

2. Get the values from servlet and form an array

3. Make use of optionsProvider  property available in selction xtype.

 

Hi Praveen,

I trying it and had this property in this way

Property OptionsProvider:

Value:

function(){ var servletPath = '/libs/dropdown?Path=$PATH';
return CQ.Util.eval(servletPath); }

but how can i add this from a listener.

Thanks,

Mani Kumar K

Translate
Mani_kumar_
New Participant
Mar 15, 2016 5:44 AM UTC

edubey wrote...

1. In listener you will make call to your servlet

2. Get the values from servlet and form an array

3. Make use of optionsProvider  property available in selction xtype.

 

Hi Praveen,

I will try and come back to you

Thanks,

Mani Kumar

Translate
edubey
Level 10
Mar 14, 2016 4:11 PM UTC

1. In listener you will make call to your servlet

2. Get the values from servlet and form an array

3. Make use of optionsProvider  property available in selction xtype.

Translate
smacdonald2008
Level 10
Mar 14, 2016 4:01 PM UTC
Mani_kumar_
New Participant
Mar 14, 2016 4:00 PM UTC
Hi praveen, Ya i tried that solution but the issue here is how can i add values to the selection xtype from listener
Translate