Display 1st Value In Dropdown Box

Use this board to ask questions or have discussions with other Rich Displays users.
sburden77
New User
Posts: 12
Joined: Wed Apr 10, 2013 2:05 pm
First Name: Stevie
Last Name: Burden
Company Name: PIC Design
Contact:

Display 1st Value In Dropdown Box

Post by sburden77 »

Hello,

How do I display the 1st value in my dropdown box instead of displaying a blank row?

When the screen displays there will be one value in the dropdown for most of our users. Currently, when the screen displays there's a blank row at the top and the user has to select the dropdown to access that one value.

Best regards
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: Display 1st Value In Dropdown Box

Post by Scott Klement »

A few things might help, depending on what's going on:
  1. Make sure the 'blank option' property on your dropdown is NOT set to 'true'. (false is the default.)
  2. Make sure the 'value' property of your dropdown is set to the value of the first option. This will prevent the user from having to select it.
Let me know if that helps.
sburden77
New User
Posts: 12
Joined: Wed Apr 10, 2013 2:05 pm
First Name: Stevie
Last Name: Burden
Company Name: PIC Design
Contact:

Re: Display 1st Value In Dropdown Box

Post by sburden77 »

Hi Scott - Thanks for replying.

I'm populating the dropdown dynamically in my program.

The "blank option" property is NOT set to "true". My "value" property is "divno" but, I'm not quite sure how to set it to the value of the first option.

Best regards
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: Display 1st Value In Dropdown Box

Post by Scott Klement »

When you say you're loading the drop-down dynamically in your program, does that mean that you have a field bound to the 'choice values' property, and you are loading that field in your program?

If so, just put the first value that you load into 'choice values' also into your 'divno' variable.

If not, please explain how you are going about loading the choices/values into your drop-down.

Thanks!
sburden77
New User
Posts: 12
Joined: Wed Apr 10, 2013 2:05 pm
First Name: Stevie
Last Name: Burden
Company Name: PIC Design
Contact:

Re: Display 1st Value In Dropdown Box

Post by sburden77 »

Scott - I tried what you suggested and its still not working.

Yes, I have a field(divisions char(200)) that's bound to the "choice values" property. Additionally, my field(divno char8)) is bound to the "value" property.

Let me explain what I'm doing.

The revision I'm adding to my program is to show in the drop down which division(s) a user has access to in order to run this report. Initially, they had access to all divisions and I would load them in the drop down by reading a table and formatting the data so it would look like this(30 - ABC Company).
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: Display 1st Value In Dropdown Box

Post by Scott Klement »

Okay, let me see if I can reproduce the problem based on your description...
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: Display 1st Value In Dropdown Box

Post by Scott Klement »

I'm unable to reproduce the problem you describe. Here's the RPG code I'm trying to use:

Code: Select all

     H DFTACTGRP(*NO)

     FDROPDOWND CF   E             WORKSTN EXTDESC('SKTEST/DROPDOWND')
     F                                     EXTFILE(*EXTDESC)
     F                                     HANDLER('PROFOUNDUI(HANDLER)')

     D divs            s             30a   dim(6)
     D code            s              8a   dim(6)
     D x               s             10i 0

      /free
       dou btnCancel = *on;

          // typically, you'd get these from a file or something,
          //  but since I don't have your files, here are a bunch
          //  of sample data for "divisions" and a code that
          //  corresponds to each division.

          divs(1) = 'Eastern';
          code(1) = 'E';
          divs(2) = 'Western';
          code(2) = 'W';
          divs(3) = 'South';
          code(3) = 'S';
          divs(4) = 'North';
          code(4) = 'N';
          divs(5) = 'United Kingdom';
          code(5) = 'U';
          divs(6) = 'Germany';
          code(6) = 'G';


          // now load divisions and their values into drop-down choices
          //   (building list dynamically in a variable)

          for x = 1 to %elem(divs);

             if x = 1;
                divnames  = divs(x);
                divisions = code(x);
             else;
                divnames  = %trimr(divnames) + ',' + divs(x);
                divisions = %trimr(divisions) + ',' + code(x);
             endif;
          endfor;


          // now set the value of the dropdown (DIVSEL field) to
          //   the code for the first division, as an example.

          divno = code(1);


          // display screen... it shows the first divsion selected:

          exfmt screen1;


          // populate the last division selected so the user can
          //  see what was selected last time the screen was
          //  displayed.

          lastDivno = divno;

         enddo;

         *inlr = *on;
      /end-free 

Here's the corresponding display file:

Code: Select all

     A          R SCREEN1
     A                                  1  2HTML('QPUIREC0    ')
     A                                  1  3HTML('{"screen":{"record format nam-
     A                                      e":"SCREEN1"},"items":[{"id":"CssBu-
     A                                      tton1","field type":"css button","v-
     A                                      alue":"Cancel","left":"251px","top"-
     A                                      :"114px","width":"90px","theme":"G -
     A                                      - Red","small button":"true","icon -
     A                                      position":"left","icon":"delete","r-
     A                                      esponse":{"fieldName":"btnCancel","-
     A                                      customTrue":"","customFalse":"","da-
     A                                      taType":"indicator","formatting":"I-
     A                                      ndicator","indFormat":"1 / 0"}},{"i-
     A                                      d":"Dropdown1","field type":"select-
     A                                       box","value":{"fieldName":"DIVNO",-
     A                                      "dataLength":"8","trimLeading":"fal-
     A                                      se","trimTrailing":"true","blankFil-
     A                                      l":"false","rjZeroFill":"false","da-
     A                                      taType":"char","formatting":"Text",-
     A                                      "textTransform":"none","designValue-
     A                                      ":"[DIVNO]"},"left":"83px","top":"4-
     A                                      5px","choices":{"fieldName":"DIVNAM-
     A                                      ES","dataLength":"200","trimLeading-
     A                                      ":"false","trimTrailing":"true","bl-
     A                                      ankFill":"false","rjZeroFill":"fals-
     A                                      e","dataType":"char","formatting":"-
     A                                      Text","textTransform":"none"},"widt-
     A                                      h":"198px","choice values":{"fieldN-
     A                                      ame":"DIVISIONS","dataLength":"200"-
     A                                      ,"trimLeading":"false","trimTrailin-
     A                                      g":"true","blankFill":"false","rjZe-
     A                                      roFill":"false","dataType":"char","-
     A                                      formatting":"Text","textTransform":-
     A                                      "none"}},{"id":"CssButton2","field -
     A                                      type":"css button","value":"Ok","le-
     A                                      ft":"143px","top":"114px","width":"-
     A                                      90px","theme":"F - Green","small bu-
     A                                      tton":"true","icon position":"left"-
     A                                      ,"icon":"check","response":{"fieldN-
     A                                      ame":"btnOkay","customTrue":"","cus-
     A                                      tomFalse":"","dataType":"indicator"-
     A                                      ,"formatting":"Indicator","indForma-
     A                                      t":"1 / 0"}},{"id":"Label1","field -
     A                                      type":"output field","css class":"l-
     A                                      abel","value":"Last division select-
     A                                      ed:","left":"58px","top":"210px","w-
     A                                      idth":"150px"},{"id":"OutputField1"-
     A                                      ,"field type":"output field","css c-
     A                                      lass":"outputField","value":{"field-
     A                                      Name":"LASTDIVNO","dataLength":"8",-
     A                                      "trimLeading":"false","trimTrailing-
     A                                      ":"true","blankFill":"false","rjZer-
     A                                      oFill":"false","dataType":"char","f-
     A                                      ormatting":"Text","textTransform":"-
     A                                      none","designValue":"[LASTDIVNO]"},-
     A                                      "left":"227px","top":"210px"}]}')
     A            BTNCANCEL      1A  H
     A            BTNOKAY        1A  H
     A            DIVISIONS    200A  H
     A            DIVNAMES     200A  H
     A            DIVNO          8A  H
     A            LASTDIVNO      8A  H 
When I run this program, the screen comes up with the first option selected (because I set divno = code(1) in the RPG)
first display.png
first display.png (7.6 KiB) Viewed 2516 times
When I make a selection and click "Ok", the program will show the corresponding code to what I displayed, and then the RPG code resets the selection back to the first one selected, and re-displays the screen and I see this:
next display.png
next display.png (7.79 KiB) Viewed 2516 times
So this all appears to work properly for me. If you run my sample program, does it fail for you? Or does it work just as it does for me? If it works as it does for me, what do you need to change to make it fail (the way you're describing)?

Thanks!
sburden77
New User
Posts: 12
Joined: Wed Apr 10, 2013 2:05 pm
First Name: Stevie
Last Name: Burden
Company Name: PIC Design
Contact:

Re: Display 1st Value In Dropdown Box

Post by sburden77 »

Okay, I'll compare your program to mine.
sburden77
New User
Posts: 12
Joined: Wed Apr 10, 2013 2:05 pm
First Name: Stevie
Last Name: Burden
Company Name: PIC Design
Contact:

Re: Display 1st Value In Dropdown Box

Post by sburden77 »

Thanks Scott, I'm all set. Posting the code helped alot.
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: Display 1st Value In Dropdown Box

Post by Scott Klement »

Glad to hear you got it working. (woo-hoo!) What ended up being the culprit?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests