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

Adding Manual Entry in Edit Combo Box to Master Lookup Table

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

  • Adding Manual Entry in Edit Combo Box to Master Lookup Table

    Hi there-

    I think someone will have fun with this one. I've looked all over, but couldn't find a technique to get this done (even though it sounds like it should be easy). I'd appreciate any suggestions you can offer:

    I have a Grid with an "Edit Combo" Lookup field (only a single field is displayed) that's working perfectly. If the user clicks the dropdown arrow, a list of available choices is shown. The user can click one the choices or can manually type an entry that's not in the list. Everything is working the way I'd like, except that I would like the user to be prompted with a question like "Would you like to add that to the Master List?". If they respond "Yes," then whatever was manually entered into the the field would create a new record in the SQL table that supplied the lookup (Ajax Callback), so that it would appear in future lookups. NOTE: The SQL table has only this field... and was created just for this lookup.

    I was trying to use the "NotInList" command to call an XBasic function with an "INSERT" SQL statement, but I don't know how to create the "prompt" where the user can choose whether to add the record to the list or not (e.g. it's a one-time description that won't be used again, so we don't want to add it to the Master List). I don't know how to pop-up the "Do you want to..." question and how to translate the response into the XBasic function.

    If you could offer some suggestions or guide me in the right direction, I'd appreciate it.

    Have a great holiday weekend.

    Phil

  • #2
    Re: Adding Manual Entry in Edit Combo Box to Master Lookup Table

    Your OnNotInList event code might look like this...

    Code:
    var newItem = this.value;
    //place this Javascript in your code, and then reference the rowNum variable.
    var rowNum = {Grid.Object}._selectedRow;
    
    A5.msgBox.show('New Entry','Do you wish add this entry to the dropdown?','ync',function(button){
        if(button == 'yes'){
        	var addlData = "__newItem=" + newItem;
        	{grid.Object}.ajaxCallback('G',rowNum,'myXbasicFunction','',addlData);
            // call your XBasic Ajax Callback
        } else if(button == 'no'){
            // code to close without saving...
        }
    });
    And your Ajax Callback might look like this...

    Code:
    function myXbasicFunction as c (e as p)
    
    debug(1)
    	
    dim newItem as c = e.__newItem	
    	
    end function
    You may want to test for empty strings and you also may need to return a refresh of the edit-combo once you've finished adding the new item to the table.

    Comment


    • #3
      Re: Adding Manual Entry in Edit Combo Box to Master Lookup Table

      David-

      First, THANK YOU for taking the time to respond... especially on a holiday weekend. It was very generous of you to spend your time and I really appreciate it.

      I've installed your code into my application. The part where it asks "If I wish to add the entry to the dropdown list" is PERFECT. I'm converting to Alpha from MS Access, so I'm just learning XBasic and Javascript... I never would have figured out how to do that.

      My only questions are:
      1) Where do I define the specific field in the "._selectedRow"? (FYI: My specific field in the Edit-Combo is called "RateDesc"). I am assuming that I'd define it in the first line variable dimension (e.g. var newItem = 'RATEDESC'), but I don't know how to format the field name.
      2) Second, I'm trying to understand the code, how will the Ajax Callback know to "add a record/item to my SQL table (called "tblRateDesc")? When I was trying to make this work, I created a SQL connection in the XBasic code and used an "INSERT" SQL statement... Obviously, that's not the best way to get where I wanted. Also, I couldn't figure out how to refer to the field value of "RateDesc" in the command (I tried a lot of things. FYI, here's what my SQL command looked like, just so you can see what I was thinking: "INSERT INTO tblRateDesc ( RateDesc ) Values (.RATEDESC);").

      If you could guide me through those last two issues, I think it will work great for me.

      Thanks again for all your help and your valuable time. I really do appreciate it.

      Phil

      Comment


      • #4
        Re: Adding Manual Entry in Edit Combo Box to Master Lookup Table

        When you're working with the OnNotInList event, you get to use "this.value" which is passed into the event automatically. You don't need to reference the Textbox control you're working with.

        newItem = this.value;

        Gives you the new value typed into the Textbox Edit-Combo control.

        What you've tried in your Ajax Callback function is exactly what you need to do. The callback is made to the server, to execute the XBasic function you've defined. The function runs and inserts the record. Here's a kind of template for getting this done. When you run your Grid under LivePreview, and an XBasic function is called, then if you have a debug(1) statement set, the code will break to the debugger and you can step through each line. You'll see in the code where and how the argument is set and then how it's accessed in the SQL Statement.

        I can from Access as well... many, many years starting with version 1.0. This is a lot more fun.

        Code:
        function AddNewItem as c (e as p)
        
        debug(1)
        
        dim cn as sql::connection
        dim rs as sql::ResultSet
        dim args as SQL::Arguments
        dim flag as l
        
        flag = cn.open("::Name::conn") 'replace conn with your AlphaDAO connection name
        
        if flag then
        	
        	args.set("myNewItem",e.__newItem)
        	
        	dim sqlCommand as c
        	
        	sqlCommand = <<%str%
        	INSERT INTO tblRateDesc (RateDesc) Values (:myNewItem)
        	%str%
        	
        	flag = cn.execute(sqlCommand,args)
        	if flag then
        			'All ok... nothing else to do
        	else
        		'there was an error - close the connection and exit
        		cn.Close()
        		dim msg as c 
        		msg = "Could not execute the query. Error reported was: " + cn.CallResult.text
        		msg = js_escape(msg)
        		dim jscmd as c 
        		jscmd = "alert('" + msg + "');"
        		AddNewItem = jscmd
        		exit function
        	end if  		
        	
        else
        	'there was an error - no connection
        	dim msg as c 
        	msg = "Could not open the connection. Error reported was: " + cn.CallResult.text
        	msg = js_escape(msg)
        	dim jscmd as c 
        	jscmd = "alert('" + msg + "');"
        	AddNewItem = jscmd
        	exit function
        end if	
        
        end function
        Last edited by Davidk; 07-06-2015, 11:27 AM.

        Comment


        • #5
          Re: Adding Manual Entry in Edit Combo Box to Master Lookup Table

          Sorry... my copy/paste went bad... I've corrected the code in the previous post.

          Comment


          • #6
            Re: Adding Manual Entry in Edit Combo Box to Master Lookup Table

            Hi David-

            Ahh... now, it makes sense... even to me! Your code did EXACTLY what I had hoped it could do (and it's already uploaded and "live" on the server). FYI, I added a message, in the XBasic code ("alert"), to tell the user that "the item has been added to the list" (I like it when software "talks" to the user).

            I never could have done this on my own! I have to learn the various javascript (js) commands that you used. So, I can't thank you enough. What's really important to me, as I develop my programming skills, is that I actually learn something that I can use in future applications... There are 3 or 4 techniques in this code alone that I know I'll be able to used in the future. I hope others can benefit from this, as well.

            THANK YOU, THANK YOU... I really appreciate your help.

            Phil

            Comment


            • #7
              Re: Adding Manual Entry in Edit Combo Box to Master Lookup Table

              My pleasure. I agree... there are some very basic techniques and code that I always utilize.

              Comment

              Working...
              X