Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook



The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic

Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.

If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.

Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.

Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Which way to populate a Dropdown

  • Filter
  • Time
  • Show
Clear All
new posts

  • Which way to populate a Dropdown

    I have gotten myself twisted around and unsure of the proper way to populate a Dropdown in Dialogs.

    My parent dropdown is an unbound control 'contactclassification' which is used to narrow down the choices in the child bound dropdown control 'contactid'.

    I originally thought I should be using cascading choices which worked correctly for new entries.
    It did not work for editing as the 'contactid' control was blank since no contactclassification had been selected. I verified that my backend database has all of the same column names as there have been problems with cascading and having different table column names. If I deselect cascading choices, contacted shows correctly for editing, but obviously does not work for new entries.

    I am now wondering if I should be using {dialog.object}.populateDropdownBox() instead. I think this would be used in the unbound control 'contactclassification' OnChange event if this is correct.

    To add excitement, the controls are in a repeating section.

    Can anybody point me in the direction I should be heading.


  • #2
    Re: Which way to populate a Dropdown

    Never done this in repeating section, but for regular dialogs, I sometimes have to cascade a drop-down up to 5 levels.
    For new records, it is no problem, but when editing, I have a fancy javascript function which I use recursively to perform time-delayed callbacks in order to correctly populate the dialog. It is the only way to do this that I am aware of.
    To get v11 to work like a Rolls Royce, you really do need to have your own custom javascript library of functions and tricks.


    • #3
      Re: Which way to populate a Dropdown

      So it sounds like you are using a combination of cascading drop downs along with some javascript code. I was thinking it might be better to not use cascading drop downs and just populate the drop downs with javascript using onChange events.

      Any chance of getting some snippets of the javascript you are using?



      • #4
        Re: Which way to populate a Dropdown

        Here's a short line from some code I have in an onRowRender event in a grid:

        {grid.Object}.populateDropdownBox('G','BILLED_STATUS',rowNum,[["Hourly Billable",0],["Do Not Bill",2],["Old",3]],true);
        It won't be much different for a {dialog.object}. You would omit the 'G' and rowNum parameters. The last one - true - means "replace existing values". This will delete existing options before adding the new ones. If you specify false, it appends your options.

        Options are specified as an array. If you store a value separate from the display value, you'd do it like this (first value is displayed, second is stored): [["Hourly Billable",0],["Do Not Bill",2],["Old",3]]

        Otherwise, this is fine: ["Hourly Billable","Do Not Bill","Old"]

        You'll need to do a wee bit of work to get the right row in your repeating section, but this is totally doable in your onChange event. You could perform an ajax callback that creates your dropdown choices and then returns the javascript calling {dialog.object}.populateDropdownBox. EG:

        function someCallback as c (e as p)
          'code to define myRepSecRow here
          someCallback = "{dialog.object}.populateDropdownBox('BILLED_STATUS:" + myRepSecRow + "',[['Hourly Billable',0],['Do Not Bill',2],['Old',3]], true);"
        end function
        Last edited by TheSmitchell; 03-12-2014, 01:14 PM. Reason: missing "
        Alpha Anywhere latest pre-release


        • #5
          Re: Which way to populate a Dropdown

          Thanks again Sarah,

          I see where you are going with this and have been playing with the last couple of days.
          My problem now is that I cannot figure out how to read a control in the dialog so that I can do a SQL lookup to populate my drop down.

          I know how to get the control value in the server-side events, but need the value before submitting. I have tried e._currentRowDataNew.controlname, but cannot get that to work.

          Thanks for your continued help


          • #6
            Re: Which way to populate a Dropdown

            Oh, Andrew you had asked for a snippet. You can place this sort of code in the dialog's onRenderComplete event:

            //init: This code populates the cascading box once dialog is loaded
            var myval = {dialog.Object}.getValue('AGENCYPARENTID');
            var myval2 = {dialog.Object}.getValue('AGENCYCONTACTID');
            if(myval) {
            	{dialog.Object}.refreshDropdownBoxChoices('AGENCYCONTACTID','ParentID=:myarg', myval + '|||N|myarg', myval2);
            For repeating section, there are a few tweaks that you may need to make.



            • #7
              Re: Which way to populate a Dropdown

              Originally posted by askoog66 View Post
              Thanks again Sarah,

              I see where you are going with this and have been playing with the last couple of days.
              My problem now is that I cannot figure out how to read a control in the dialog so that I can do a SQL lookup to populate my drop down.

              I know how to get the control value in the server-side events, but need the value before submitting. I have tried e._currentRowDataNew.controlname, but cannot get that to work.

              Thanks for your continued help
              Is this in an ajax callback? Or the xbasic portion of the OnChange event? A dropdown in a repeating section on a dialog, correct?
              Alpha Anywhere latest pre-release


              • #8
                Re: Which way to populate a Dropdown


                It is an Ajax callback firing out of the Javascript onChange event for the initial 'contactclassification' drop down. I am trying to call an internal xBasic function that will then populate the second 'contactid' drop down which is a bound control based on the value of the unbound control 'contactclassification'

                I think I can get it if I can figure out how to get the value from the first drop down. I read on the forums that maybe e._currentRowDataNew.contaclassification was the way to go but cannot get that to work. I obviously have to get the value before the form is submitted.

                Both drop downs are displaying text, but returning integer e.g. "John Q. Public", 2014002

                Both of these are in a repeating section.

                Selwyn's D41 videos seem to apply but he is using A5.form.populateSelect whereas I am using (dialog.object}.populateDropdownBox. I have lost track of where I read that in the forum, but am assuming this is just one other way to 'skin the cat'. He is not basic any of his choices from another control either, which is what is throwing me for the moment.



                • #9
                  Re: Which way to populate a Dropdown


                  I tried my best to do in xBasic but couldn't pull it off and went for your Javascript solution which ended up being much less code, but I loathe Javascript.

                  It works in my repeating section as desired except for one undesirable messes up the display of the drop down in other rows. e.g.
                  Previous repeating section rows display Bert's Plumbing, but store contactid of 2014050. As soon as I add a row and change the unbound classification, the previous row now displays 2014050. I tried changing the optional currentRowOnly setting in {dialog.Object}.refreshDropdownBoxChoices to false and true and saw no change in either case.

                  I am wondering if this has something to do with my off-standard select statement in the drop down query. I am having to select 3 columns, not 2 in order to supply my third column to do the filter. I select contactname, contactid, contactclassid from my table to supply the drop down data.

                  Obviously, only a problem in repeating sections, but cannot seem to find the solution for the display issue. Didn't know if you had run into similar problems.

                  Javascript code is as follows
                  var vcontactclass = {dialog.Object}.getValue('CONTACTCLASSIFICATION');
                  {dialog.Object}.refreshDropdownBoxChoices('CONTACTID', 'contactclassid=:whatclass', vcontactclass + '|||n|whatclass');


                  • #10
                    Re: Which way to populate a Dropdown

                    This is straight from the function reference:
                    {dialog.Object}.refreshDropdownBoxChoices(controlName [,dynamicFilter [,dynamicFilterArguments [,selectedValue [,currentRowOnly]]]]);

                    Note that you need to set the currentrowonly parameter to 'true' if you only wish the current row to be refreshed.