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

Problem with selected item in refreshing dropdown

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

    Problem with selected item in refreshing dropdown

    I have a UX with dropdown lists that I use to move files around. Each dropdown shows the files in a particular directory which I get using filefind.get(). The pics show the problem. I select a file in the first pic and click "move". This does an ajax callback that copies the file to the new directory, then removes it from the old directory.

    vFileFrom = vPath+chr(92)+"NFNWIP"+chr(92)+e._currentRowDataNew.WIPFILES
    vFileTo = vPath+chr(92)+"Inspection"+chr(92)+e._currentRowDataNew.WIPFILES
    file.copy(vFileFrom,vFileTo)
    file.remove(vFileFrom)

    then, I refresh the directories

    vWIP = filefind.get(vPath+chr(92)+"NFNWIP\*.*",FILE_FIND_NOT_DIRECTORY,"N")
    if vWIP = ""
    vWIP = "No files found"
    end if
    vWIP = js_list_to_array(vWIP)
    WIPjs = "{dialog.Object}.populateDropdownBox('WIPFILES',"+vWIP+",true);"

    The file is moved and shows in the new directory, but it still also shows in the old directory even though it is not there.

    Seems that, as long as the file is selected, the populate... continues to show it. Selecting a different file, I can then refresh with the populate... function and it disappears.

    So, how can I change the "selected" file or set selected to none in the dropdown before doing the populate... step?

    Capture1.PNGCapture2.PNGCapture3.PNG
    Pat Bremkamp
    MindKicks Consulting

    #2
    Re: Problem with selected item in refreshing dropdown

    Wow, it looks like the wiki does not give proper examples of that populateDropdownBox: http://wiki.alphasoftware.com/~alpha...downBox+Method

    Looks like their examples don't include a proper array syntax for the second parameter.

    Anyway, Pat when you run the code are you perhaps having windows explorer browser the source folder. I have found just having Windows explorer open and with a file selected, even though the preview window is off, that it maintains some sort of lock on the file and that you cannot do certain things with the file using another program.

    Comment


      #3
      Re: Problem with selected item in refreshing dropdown

      Thanks Rich,
      I used one of the videos to get the parameters for the function.
      Unfortunately, the windows explorer browser is not being used. Any other ideas?
      Pat Bremkamp
      MindKicks Consulting

      Comment


        #4
        Re: Problem with selected item in refreshing dropdown

        Those listboxes don't look like dropdown boxes. For a 'list' control would it be better to use the 'populate()' function of a list control?


        var listObj = {dialog.object}.getControl('LIST1');
        var _d = [
        {firstname: 'John', lastname: 'Smith'},
        {firstname: 'Fred', lastname: 'Harris'}
        ]
        listObj.populate(_d);

        Comment


          #5
          Re: Problem with selected item in refreshing dropdown

          I tried using list controls instead of dropdown boxes, but had trouble getting the value of the selected file to use in the callbacks. I need to use Xbasic in order to get the list of files in the directory and to move and remove the files, along with uploading (user defined) and downloading. Those are server side activities. There are no tables used in this; the dropdowns are populated initially from variables, then updated when things change using this populateDropDown... functions.

          I need the javascript to remove or change the selection so I can update the screen.
          Pat Bremkamp
          MindKicks Consulting

          Comment


            #6
            Re: Problem with selected item in refreshing dropdown

            Originally posted by RichCPT View Post
            Wow, it looks like the wiki does not give proper examples of that populateDropdownBox: http://wiki.alphasoftware.com/~alpha...downBox+Method

            Looks like their examples don't include a proper array syntax for the second parameter.
            It does not have a proper example. Here's your proper examples:

            Code:
            //Populate the choices in the Dropdown Box for the 'COMPANY' field. Add the new choices to the existing choices.
            {dialog.Object}.populateDropdownBox('COMPANY',['A2','B2','C2'],false);
            
            //Populate the choices in the Dropdown Box for the 'COMPANY' field. Replace the existing choices. Each new choice that is added has both a display and stored value.
            {dialog.Object}.populateDropdownBox('COMPANY',[['alpha 2','A2'],['beta 2','B2'],['display for c','C2']],true);
            The wiki is interpreting the array brackets as a web link --- le sad. I have sent in several reports about this (I think? Maybe I'm hallucinating this one...)
            Alpha Anywhere latest pre-release

            Comment


              #7
              Re: Problem with selected item in refreshing dropdown

              Originally posted by Pat Bremkamp View Post
              I tried using list controls instead of dropdown boxes, but had trouble getting the value of the selected file to use in the callbacks. I need to use Xbasic in order to get the list of files in the directory and to move and remove the files, along with uploading (user defined) and downloading. Those are server side activities. There are no tables used in this; the dropdowns are populated initially from variables, then updated when things change using this populateDropDown... functions.

              I need the javascript to remove or change the selection so I can update the screen.
              Couldn't you just call {dialog.object}.setValue("LIST","") to change the selection?
              Alpha Anywhere latest pre-release

              Comment


                #8
                Re: Problem with selected item in refreshing dropdown

                Sarah,

                Thanks for your suggestion. That makes perfect sense. I've just tried it using
                {dialog.Object}.setValue('WIPFILES','');{dialog.Object}.populateDropdownBox('WIPFILES',"+vWIP+",true);
                but there was no change... maybe there is a timing issue?
                Isn't there some sort of "do this then that" or timeout kind of thingy?
                Pat Bremkamp
                MindKicks Consulting

                Comment


                  #9
                  Re: Problem with selected item in refreshing dropdown

                  Originally posted by Pat Bremkamp View Post
                  Sarah,

                  Thanks for your suggestion. That makes perfect sense. I've just tried it using
                  {dialog.Object}.setValue('WIPFILES','');{dialog.Object}.populateDropdownBox('WIPFILES',"+vWIP+",true);
                  but there was no change... maybe there is a timing issue?
                  Isn't there some sort of "do this then that" or timeout kind of thingy?
                  Do you have code that you call when the client changes their selection in the dropdown list control?
                  Alpha Anywhere latest pre-release

                  Comment


                    #10
                    Re: Problem with selected item in refreshing dropdown

                    Thanks for sticking with me on this.

                    No, there is no code that runs when the selection changes. All the code runs in Ajax callbacks and the Javascript is called by putting the javascript into the callback function name.

                    I use callbacks because, in addition to moving values on the screen, I am moving files on the server.
                    Pat Bremkamp
                    MindKicks Consulting

                    Comment


                      #11
                      Re: Problem with selected item in refreshing dropdown

                      Originally posted by Pat Bremkamp View Post
                      Thanks for sticking with me on this.

                      No, there is no code that runs when the selection changes. All the code runs in Ajax callbacks and the Javascript is called by putting the javascript into the callback function name.

                      I use callbacks because, in addition to moving values on the screen, I am moving files on the server.
                      Not a problem!

                      I did a bit of digging around (http://stackoverflow.com/questions/3...-multiple-sele). I think the issue lies somewhere on Alpha's end. It's trying to restore the selected value after repopulating the dropdown boxes.

                      If you add this little line *after* you call populateDropdownBox, it should clear things up (I tested it!) If you call it before, populateDropdownBox selects the first option in the list. Or the empty space beyond the end.

                      Code:
                      $('{dialog.componentName}.V.R1.WIPFILES').options.selectedIndex = -1;
                      See attached example! You'll have to replace my hard-coded file names, but you get the idea.
                      ---
                      Sarah
                      Attached Files
                      Last edited by TheSmitchell; 07-31-2014, 12:26 PM.
                      Alpha Anywhere latest pre-release

                      Comment


                        #12
                        Re: Problem with selected item in refreshing dropdown

                        PS: Ignore the code errors you may find
                        Alpha Anywhere latest pre-release

                        Comment


                          #13
                          Re: Problem with selected item in refreshing dropdown

                          AAAAALLLLSSSOOOOO, I figured out Alpha was restoring the selected value/index by looking at the code in Google Chrome. If you type in a function without the () stuff in the console window, Chrome prints the contents of the function:
                          Code:
                          > DLG1_DlgObj.populateDropdownBox
                          < function (columnName,data,clearExisting) {
                          		var curData = '';
                          		var ele = this._getControlLow(columnName);
                          		if(ele) {
                          			curData = this.getValue(columnName);
                          			A5.form.populateSelect(ele,curData,data,clearExisting);
                          		}
                          	} 
                          > A5.form.populateSelect
                          < function (eleId,currValue,data,clearExistingEntries) {
                          	//call old function if clearExistingEntries is a string, not a boolean
                          	if(typeof clearExistingEntries == 'string') {
                          		a5_AJAX_Form_populateSelect(eleId,currValue,data,clearExistingEntries);
                          		return false;
                          	}
                          	var ele = $(eleId);
                          	var currIndex = 0;
                          	if(clearExistingEntries) {
                          		if(ele.options.length > 0) {
                          			for(var i = ele.options.length -1; i >= 0; i--) ele.options[i] = null;
                          			ele.options[0] = null;
                          		}
                          	} else currIndex = ele.options.length;
                          	for(var i =0; i < data.length; i++) {
                          		if(data[i].constructor == Array) {
                          			if(data[i].length > 1) {
                          				ele.options[currIndex] = new Option(data[i][0],data[i][1]);	
                          			} else {
                          				ele.options[currIndex] = new Option(data[i][0],data[i][0]);
                          			}
                          		} else {
                          			ele.options[currIndex] = new Option(data[i],data[i]);
                          		}
                          		currIndex++;
                          	}
                          	var optionFound = false;
                          	if(ele.options.length > 0) {
                          		for(var i = 0; i < ele.options.length; i++) {
                          			if(ele.options[i].value == currValue) {
                          				optionFound = true;
                          				ele.options.selectedIndex = i;
                          				break;
                          			}
                          		}
                          		if(optionFound == false) {
                          			ele.options[ele.options.length] = new Option(currValue,currValue);
                          			ele.options.selectedIndex = ele.options.length -1;
                          		}
                          	}
                          }
                          Alpha Anywhere latest pre-release

                          Comment


                            #14
                            Re: Problem with selected item in refreshing dropdown

                            Sarah,

                            Thanks for the code. That is much better.
                            I find that the file name is remaining, but it is not selected, so it will disappear just by clicking "refresh". Much more intuitive.
                            Pat Bremkamp
                            MindKicks Consulting

                            Comment


                              #15
                              Re: Problem with selected item in refreshing dropdown

                              Originally posted by Pat Bremkamp View Post
                              Sarah,

                              Thanks for the code. That is much better.
                              I find that the file name is remaining, but it is not selected, so it will disappear just by clicking "refresh". Much more intuitive.
                              If the filename lingers, you may want to do selectedIndex = -1 twice (once before the populateDropdownBox call and one after; or just call {dialog.object}.setValue('FIELD','',false) before the populate.) The populateDropdownBox process gets the current value of the element, repopulates the choices, and then flagrantly violates the "do nothing" rule by adding the old current value back to the list if it doesn't exist! In my tests, both lists updated properly. But, it's possible that I *thought* I tested it with just the call after populate but actually didn't (because at one point, I was doing selectedIndex = -1 twice.)

                              At any rate, glad I could help out! I learned quite a bit about FILEFIND during this exercise. :D
                              Alpha Anywhere latest pre-release

                              Comment

                              Working...
                              X