setting the value of a dropdown

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
Thomas Garvey
Profound User
Posts: 22
Joined: Fri Jul 30, 2010 1:37 pm
First Name: Thomas
Last Name: Garvey
Company Name: Unbeaten Path Intl
Phone: 630-462-3991
State / Province: Illinois
Zip / Postal Code: 60188
Country: United States
Contact:

setting the value of a dropdown

Post by Thomas Garvey »

I am able to populate the dropdown from rpg (not a database file), and the choices, but I am not able to set the value of the dropdown before display.
That is, if I had a dropdown with Options 1 through 5, I need to have it show Option 3 as the current selection of that dropdown when the panel is first displayed. Nothing I'm doing is working and I see no examples of setting the selection in any of the Samples.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: setting the value of a dropdown

Post by Scott Klement »

What you need to do is bind a field to the "value" property. Have this match the "choices value" that you want to set as the "set value".

Since you say there are no examples, I'll provide one here. Here's the DDS:

Code: Select all

     A                                      INDARA
     A          R REC
     A                                  1  2HTML('QPUIREC0    ')
     A                                  1  3HTML('{"screen":{"record format nam-
     A                                      e":"rec"},"items":[{"id":"Dropdown1-
     A                                      ","field type":"select box","value"-
     A                                      :{"fieldName":"value","dataLength":-
     A                                      "10","trimLeading":"false","trimTra-
     A                                      iling":"true","blankFill":"false","-
     A                                      rjZeroFill":"false","dataType":"cha-
     A                                      r","formatting":"Text","textTransfo-
     A                                      rm":"none","designValue":"[value]"}-
     A                                      ,"left":"58px","top":"33px","choice-
     A                                      s":{"fieldName":"choices","dataLeng-
     A                                      th":"100","trimLeading":"false","tr-
     A                                      imTrailing":"true","blankFill":"fal-
     A                                      se","rjZeroFill":"false","dataType"-
     A                                      :"char","formatting":"Text","textTr-
     A                                      ansform":"none"},"width":"173px","c-
     A                                      hoice values":{"fieldName":"values"-
     A                                      ,"dataLength":"100","trimLeading":"-
     A                                      false","trimTrailing":"true","blank-
     A                                      Fill":"false","rjZeroFill":"false",-
     A                                      "dataType":"char","formatting":"Tex-
     A                                      t","textTransform":"none"}},{"id":"-
     A                                      Button1","field type":"button","css-
     A                                       class":"button","value":"Ok","left-
     A                                      ":"26px","top":"104px","width":"100-
     A                                      px","cursor":"default","response":{-
     A                                      "fieldName":"btnOkay","customTrue":-
     A                                      "","customFalse":"","dataType":"ind-
     A                                      icator","formatting":"Indicator","i-
     A                                      ndFormat":"1 / 0"}},{"id":"Button2"-
     A                                      ,"field type":"button","css class":-
     A                                      "button","value":"Exit","left":"150-
     A                                      px","top":"104px","width":"100px","-
     A                                      cursor":"default","response":{"fiel-
     A                                      dName":"btnExit","customTrue":"","c-
     A                                      ustomFalse":"","dataType":"indicato-
     A                                      r","formatting":"Indicator","indFor-
     A                                      mat":"1 / 0"}}]}')
     A            BTNEXIT        1A  H
     A            BTNOKAY        1A  H
     A            CHOICES      100A  H
     A            VALUE         10A  H
     A            VALUES       100A  H
Here's the RPG code:

Code: Select all

     H DFTACTGRP(*NO)

     FDROPVALD  CF   E             WORKSTN EXTDESC('SKTEST/DROPVALD')
     F                                     EXTFILE(*EXTDESC)
     F                                     HANDLER('PROFOUNDUI(HANDLER)')
      /free
         choices = 'Red,Blue,Orange,Green,Yellow,Brown,White,Black';
         values  = 'R,BL,O,G,Y,BR,W,BK';

         value = 'Y'; // start with yellow.

         dou btnExit = *on;
            exfmt rec;
         enddo;
         *inlr = *on;
When you run this, you'll see that "YELLOW" comes up as the default choice, because the VALUE field is set to Y. Even though "Red" is first in the list, Yellow is the value because of the Y in the "value" property.
dropvald.png
dropvald.png (2.82 KiB) Viewed 641 times
Thomas Garvey
Profound User
Posts: 22
Joined: Fri Jul 30, 2010 1:37 pm
First Name: Thomas
Last Name: Garvey
Company Name: Unbeaten Path Intl
Phone: 630-462-3991
State / Province: Illinois
Zip / Postal Code: 60188
Country: United States
Contact:

Re: setting the value of a dropdown

Post by Thomas Garvey »

Thanks, Scott.
Real problem turned out to be the length of the Choices and Choices Values fields. They defaulted to 10, but must be defined long enough to contain all elements, delineated by commas. Also, I was setting the selection based on the Choices (those actually displayed), when it must be set using the Choices values (those used internally).
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: setting the value of a dropdown

Post by Scott Klement »

Yep, you're completely correct there, Thomas.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest