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

Announcement

Collapse

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

Grid Component - New Method to Set Choices in DropdownBox Control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Grid Component - New Method to Set Choices in DropdownBox Control

    I wrote to Selwyn to ask if there was a way to re populate a dropdown box when it gets the focus, and he very nicely responded with info below, but I'm not experienced enough to actually use it. Here's his info:

    From Selwyn:----------------------------------------------------------
    you can only repopulate a dropdown box using an ajax callback. here is an excerpt from the release notes.

    Grid Component - New Method to Set Choices in DropdownBox Control - A new Grid method has been added to allow you to dynamically reset the choices in a DropdownBox control.
    {Grid.object}.populateDropdownBox(part,columnName,rowNum,data,clearExisting)

    part G or D (depending on whether the control is in the Grid or Detail View part
    columnName Name of the field. (Must be uppercase)
    rowNum Row number of the control. For Detail View is 1.
    data Array of choices. Each entry in the array can be an item, or an array with a display and stored value.
    Examples:
    ['alpha','beta','gamma']
    [ ['alpha','a'], ['beta','b'], ['gamma','g']

    clearExisting if true, the existing choices in the control are removed before the new choices are added
    End of Selwyn info--------------------------------------------------

    Here's some of my dropdown box Xbasic properties. Can anyone give me a clue as to how to fill in the line that Selwyn suggested for an ajax callback? I think he wants me to figure it out myself, but still learning....

    DropDownBox.Datasource = "CS"
    .DropDownBox.maxchoices = 0
    .DropDownBox.CS.ConnectionString= "::name::DynamicConnection_CHS"
    .DropDownBox.CS.SQL = "SELECT DISTINCT DOC_TYPE FROM TblDoxTypes ORDER BY DOC_TYPE"
    .DropDownBox.DisplayValueField = "DOC_TYPE"
    .DropDownBox.DisplayValueFieldType = "C"
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    #2
    Re: Grid Component - New Method to Set Choices in DropdownBox Control

    Well, I'm half guessing may way through this. Using info in previous post and info here: http://wiki.alphasoftware.com/SQL+Re...xtRow+Function

    Here's my little Jing about what I'm trying to do: http://screencast.com/t/bL4RTiKnF

    I have the following code in the OnFocus event for the field DOC_TYPE that is a dropdown box field. When I debug, I can see that my variable result is filling with a list of the data in the DOC_TYPE field, but my dropdown box does NOT repopulate. I've tried putting the {grid.Object}.populateDropdownBox line both inside and out of the while loop. Any ideas?

    Code:
    dim cn as sql::connection
    dim cs as c 
    
    'get the connection string that is defined in this Grid component
    cs = e.session.__protected__xxx
    cn.open(cs)
    
    dim sql as c 
    
    sql = "Select DOC_TYPE from TblDoxTypes"
    
    cn.Execute(sql)
    
    dim rs as sql::resultset
    rs = cn.ResultSet
    		
    dim result as c
    
    while (rs.NextRow())
         result = result + rs.data("DOC_TYPE") + crlf()
        	
    end while
    	
    dim jscmd as c 
    jscmd = <<%js%
    {grid.Object}.populateDropdownBox('G','DOC_TYPE',({Grid.RowNumber}),result,true);
    %js%
    Last edited by kingcarol; 02-23-2011, 09:15 PM.
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    Comment


      #3
      Re: Grid Component - New Method to Set Choices in DropdownBox Control

      I think it needs to be a javascript array but i have not tested the latest version.
      it looks similar to
      A5.form.populateSelect

      You can generate an xBasic variable in required format then replace the result reference in jscmd using stritran.
      Last edited by mumfie; 02-24-2011, 04:28 AM.
      https://appsbydesign.co.uk/

      Comment


        #4
        Re: Grid Component - New Method to Set Choices in DropdownBox Control

        I think I give up. Will probably just use the Auto Suggest. Edit Combo isn't good for heavy accounting data entry because of the choice switching when you type 2nd letter. I was hoping that users could see all selections in a drop down list without being limited to ones for first letter typed (as in Auto Suggest), but if I have a button to right of field that displays the whole list, I guess that's good enough. Plus I have a feeling I'm going to make use of a lot of the features available with auto suggest.
        Carol King
        Developer of Custom Homebuilders' Solutions (CHS)
        http://www.CHSBuilderSoftware.com

        Comment


          #5
          Re: Grid Component - New Method to Set Choices in DropdownBox Control

          Is the selector type [begins,contains etc] not the criteria todo this?

          Comment


            #6
            Re: Grid Component - New Method to Set Choices in DropdownBox Control

            I apologize for being such a javascript novice, but I don't know what you mean by 'selector type'??
            Carol King
            Developer of Custom Homebuilders' Solutions (CHS)
            http://www.CHSBuilderSoftware.com

            Comment


              #7
              Re: Grid Component - New Method to Set Choices in DropdownBox Control

              Asked Selwyn to look at this thread, but he replied that I needed to open a support incident, so will just go on and use auto-suggest instead. ALTHOUGH, now I have to figure out how to make auto-suggest work for looking up numeric account numbers, etc. Is going to be a long, long job trying to move a full accounting, job costing application to web, methinks.
              Carol King
              Developer of Custom Homebuilders' Solutions (CHS)
              http://www.CHSBuilderSoftware.com

              Comment


                #8
                Re: Grid Component - New Method to Set Choices in DropdownBox Control

                Carol I setup a Jing after the weekend , oke?

                Comment


                  #9
                  Re: Grid Component - New Method to Set Choices in DropdownBox Control

                  That's wonderful, Eric! I'm finding that the auto suggest is giving me some features that I like, but I think that as I get more into developing the accounting data entry grids, I'm going to want the dropdown box, so I will look forward to your Jing.
                  Carol King
                  Developer of Custom Homebuilders' Solutions (CHS)
                  http://www.CHSBuilderSoftware.com

                  Comment


                    #10
                    Re: Grid Component - New Method to Set Choices in DropdownBox Control

                    Here's a sample database using the populateDropDownbox method in an ajax callback.

                    LASTNAME on the grid is a dropdown with an Onfocus event calling an ajax callback which calls the xbasic function popDropDown.

                    The xbasic function popDropDown grabs lastnames from employees table and builds a simple array for populateDropDownbox.

                    Comment


                      #11
                      Re: Grid Component - New Method to Set Choices in DropdownBox Control

                      Thanks so much, David! As a result of studying your code, I have rewritten mine to the example shown below... AND IT'S WORKING! This message board ROCKS!

                      Code:
                      dim cn as sql::connection
                      dim cs as c 
                      
                      'get the connection string that is defined in this Grid component
                      cs = e.session.__protected__xxx
                      cn.open(cs)
                      
                      dim sql as c 
                      
                      sql = "Select DOC_TYPE from TblDoxTypes"
                      
                      cn.Execute(sql)
                      
                      dim rs as sql::resultset
                      rs = cn.ResultSet
                      		
                      'Build the result set in the format needed for the populateDropDownBox method.
                      'Format example from Alphapedia:  result = "['alpha1','beta1','gamma1']"
                      		
                      dim result as c
                      result = "["
                      
                      while (rs.NextRow())
                           result = result + "'" + rs.data("DOC_TYPE") + "',"
                      end while
                      
                      'The above will result in a string that ends in a comma after the last Doc Type, so we need to get rid of that last comma.
                      'Put a ] at the end of the line before we do strtran so that we can identify where the unwanted ending comma is.
                      result = result + "]"
                      
                      'Now replace the ,] at the end of the line with just the ]
                      result = strtran(result,",]","]")
                      	
                      PopulateDropdownDocType = "{grid.Object}.populateDropdownBox('G','DOC_TYPE',({Grid.RowNumber}),"+result+",1);"
                      Carol King
                      Developer of Custom Homebuilders' Solutions (CHS)
                      http://www.CHSBuilderSoftware.com

                      Comment


                        #12
                        Re: Grid Component - New Method to Set Choices in DropdownBox Control

                        very nice, although the code that turns a resultset into a javascript array could be optimized as follows:


                        Code:
                        dim cn as sql::connection
                        flag = cn.open("::Name::SQLServer_Northwind")
                        flag = cn.Execute("select distinct city from customers order by city")
                        dim txt as c 
                        txt = cn.ResultSet.ToString()
                        txt = JS_list_to_array(txt)
                        if you examine txt, you will see that it looks like this:

                        Code:
                        ['London','Madrid','Paris']
                        Last edited by Selwyn Rabins; 02-25-2011, 05:12 PM.

                        Comment


                          #13
                          Re: Grid Component - New Method to Set Choices in DropdownBox Control

                          Cool, Selwyn, thanks for the tip!
                          Carol King
                          Developer of Custom Homebuilders' Solutions (CHS)
                          http://www.CHSBuilderSoftware.com

                          Comment


                            #14
                            Re: Grid Component - New Method to Set Choices in DropdownBox Control

                            Thanks for this post. It got me started on a similar solution. I had to populate three dropdowns all based on the selection in the first dropdown. I also needed to use a Diaplay and Stored Value, so I converted my results to the required format using long hand like Carol.

                            I apologize in advance for naming one of my fields "object" as you can see below.:o

                            Code:
                            dta = "alltrim(name)+'|^|'+id"
                            result_size 	= table.external_record_content_get("[PathAlias.ADB_Path]\object_size",dta,"name","object_id="+e._currentRowDataNew.object)
                            result_type 	= table.external_record_content_get("[PathAlias.ADB_Path]\object_type",dta,"name","object_id="+e._currentRowDataNew.object)
                            result_material = table.external_record_content_get("[PathAlias.ADB_Path]\object_material",dta,"name","object_id="+e._currentRowDataNew.object)
                            
                            dim lst as c
                            
                            lst = "["
                            for each foo in result_size
                            	lst = lst + "['" + word(foo,1,"|^|") + "','" + word(foo,2,"|^|") + "'],"
                            next	
                            lst = lst + "]"
                            result_size = stritran(lst,"],]","]]")
                            
                            lst = "["
                            for each foo in result_type
                            	lst = lst + "['" + word(foo,1,"|^|") + "','" + word(foo,2,"|^|") + "'],"
                            next	
                            lst = lst + "]"
                            result_type = stritran(lst,"],]","]]")
                            
                            lst = "["
                            for each foo in result_material
                            	lst = lst + "['" + word(foo,1,"|^|") + "','" + word(foo,2,"|^|") + "'],"
                            next	
                            lst = lst + "]"
                            result_material = stritran(lst,"],]","]]")
                            
                            'save_to_file(result_size,"c:\si.txt")
                            
                            getChoices = "{grid.Object}.populateDropdownBox('G','OBJECT_SIZE',({Grid.RowNumber}),"+result_size+",1);{grid.Object}.populateDropdownBox('G','OBJECT_TYPE',({Grid.RowNumber}),"+result_type+",1);{grid.Object}.populateDropdownBox('G','OBJECT_MATERIAL',({Grid.RowNumber}),"+result_material+",1);"
                            Last edited by Steve Wood; 03-17-2011, 09:37 AM. Reason: altered code
                            Steve Wood
                            See my profile on IADN

                            Comment


                              #15
                              Re: Grid Component - New Method to Set Choices in DropdownBox Control

                              Such good work in this thread... I can see turning this code into a much used function.

                              Comment

                              Working...
                              X