Selection Dropdown values dynamically. | Community
Skip to main content
Mani_kumar_
New Participant
March 14, 2016
Solved

Selection Dropdown values dynamically.

  • March 14, 2016
  • 11 replies
  • 6711 views

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.
Best answer by Mani_kumar_

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
January 23, 2019

Hi Mani,

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

Regards,

Vidya AV

New Participant
July 11, 2017

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

edubey
New Participant
March 15, 2016

Great!!...

Mani_kumar_
Mani_kumar_AuthorAccepted solution
New Participant
March 15, 2016

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);
                        });
 }

edubey
New Participant
March 15, 2016

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

Mani_kumar_
New Participant
March 15, 2016

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

Mani_kumar_
New Participant
March 15, 2016

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

edubey
New Participant
March 14, 2016

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.

smacdonald2008
New Participant
March 14, 2016
Mani_kumar_
New Participant
March 14, 2016
Hi praveen, Ya i tried that solution but the issue here is how can i add values to the selection xtype from listener