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

Accessing Multi-Select List Control Array To Pull Out Any Desired Data..

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

    Accessing Multi-Select List Control Array To Pull Out Any Desired Data..

    I will start off by saying that this is NOT a question - this is purely informational. I hope this helps someone that experiences issues with pulling out array data from multi-select lists.

    Brief:

    I started off by creating a multi-select list control for displaying all employees within the organization. The idea behind this was obviously to allow employees to be managed by an HR department within the application itself. Of course, I included some basic features like creating new employees, editing existing employees and so on..

    Skipping ahead a week, I was informed by my client that the HR department needed to be able to send out notifications via email, whether individually or in bulk. So I thought, "well, I have this HR module thing.. why not include it there?"..

    Moving on.. I got everything set up the way I wanted and got to the point where it was time to actually focus on the notifications. I knew there were a lot of different ways I could do this, but for simplicity sake, I thought "it would probably be cool to allow HR to just select the employees they want to notify in the list, click a button, draft the email and send" (e.g. not having to input email addresses for every person they wanted to send the same notification to). The problem I had was getting the email addresses from the rows that were selected in the list. Having worked with list controls in the past, I knew about the selectionData array and how to access it. However, when I started actually writing the javascript, I could not for the life of me figure out how to pull only the email addresses from the selected rows in the array. Needless to say, I fiddled with this for almost an entire day in console. Initially, I was getting undefined errors left and right, then I finally got something promising in the form of [Object Object] while I was running in console which told me I was on the right track (for some odd reason, as I was getting the message a number of times depending on how many rows I had selected which told me that I was accessing the objects in the array).

    Eventually, I was able to pull what I needed from the array and get it working via (in list's OnSelect event):

    Code:
    if (this.initialized){
    	
    	var lObj = {dialog.object}.getControl('list1'); //targeting list control
    	var selectData = lObj.selectionData; //grabbing selected list data
    	var lstArray = []; 
    
    	for(i=0;i<selectData.length;i++){
         	   var newArray = [];
         	   newArray = lstArray.push(selectData[i].listColumn);
    	}
    	
    	var myArray = [].concat(lstArray); //Created fresh array and put lstArray data in
    	var joinedArray = myArray.join(','); //Separating email addresses w/ comma for multiple recipients
    		
            {dialog.object}.setValue('textfield',joinedArray); //My email recipient field where selected employee's email addresses are output to
    }

    If there was a better and more efficient way to do this - please feel free to enlighten me.. I feel like I ran around this multiple times trying a million different things to get this working. But again, hopefully this will help someone out somewhere down the line..
    Last edited by txsiccness; 04-01-2016, 03:08 PM.

    #2
    Re: Accessing Multi-Select List Control Array To Pull Out Any Desired Data..

    If my notes are correct, refer to the two videos under "UXL_V12--42" in the video library.
    From my notes, I think this is how I would go about processing a particular column value from the rows that have been selected:

    Code:
    var dat = '';
    var lObj = {dialog.Object}.getControl('YOUR_LIST');
    var slctCnt = lObj.selection.length;
    for( var j=0; j < slctCnt; j++ ) {
       dat = lObj.selectionData[j].YOUR_FIELD_NAME;    // Use LIST / Fields (tab) to get proper up/low case of field name.
       // do something here with 'dat'
    }
    As DavidK mentioned today or yesterday in another post, there are a number of useful properties for a LIST object: .selection, .selectionKey, selectionData, .value

    Comment


      #3
      Re: Accessing Multi-Select List Control Array To Pull Out Any Desired Data..

      Originally posted by txsiccness View Post

      Code:
      if (this.initialized){
      	
      	var lObj = {dialog.object}.getControl('list1'); //targeting list control
      	var selectData = lObj.selectionData; //grabbing selected list data
      	var lstArray = []; 
      
      	for(i=0;i<selectData.length;i++){
           	   var newArray = [];
           	   newArray = lstArray.push(selectData[i].listColumn);
      	}
      	
      	var myArray = [].concat(lstArray); //Created fresh array and put lstArray data in
      	var joinedArray = myArray.join(','); //Separating email addresses w/ comma for multiple recipients
      		
              {dialog.object}.setValue('textfield',joinedArray); //My email recipient field where selected employee's email addresses are output to
      }

      If there was a better and more efficient way to do this - please feel free to enlighten me.. I feel like I ran around this multiple times trying a million different things to get this working. But again, hopefully this will help someone out somewhere down the line..
      Riley,

      I understand what you want to accomplish, but there are a few issues with your code.

      You're using the List Control onSelect event... and... you're using if(this.initialized) which means that you're not allowing a null value for the List. But, this means that the first row in the List is automatically selected for your user.

      The onSelect code fires if you select a row, but does not fire if you de-Select a row. Once an email is added to your List, your can't un-add it.

      Because you're using the onSelect event, your code, which processes ALL selected rows, fires every time and process ALL selected rows every time a row is selected.

      Because you're using the onSelect event, you don't need to get the List object again with the .getControl() method. You have all the List object info in the 'this' scope.

      You're creating a new Array (selectData) by making it a copy of lObj.selectionData. Why create a new Array of identical data?

      In your loop, you're creating a newArray but not using it as an array. It ends up being a counter of Array items. The .push() method does not need to be assigned.
      Also, you're creating this new Array every time you loop.

      You then create a 4th Array (myArray) and assign it 1stArray. Why create a duplicate Array of selected data?

      Then you create a variable named joinedArray which is not an Array but rather a string of comma separated values.


      I would "check" the List property "Allow NULL selection".

      I would add a button to your UX... allow your users to select Email addresses and then click the button to process their selections.

      The code would be...

      Code:
      	var lObj = {dialog.Object}.getControl('list1'); //targeting list control
      	var emailArray = []; 
      
      	for(i=0;i<lObj.selectionData.length;i++){
      		emailArray.push(lObj.selectionData[i].EMAIL);
      	}
      
      	var emailStr = emailArray.join(',');
      	{dialog.object}.setValue('textEmails',emailStr);
      If you really wanted to process all selections every time you make a selection, then use the onClick event instead of onSelect as onClick fires for de-Select as well.

      Comment


        #4
        Re: Accessing Multi-Select List Control Array To Pull Out Any Desired Data..

        Ahhh, very nice David! Solid work.

        Comment

        Working...
        X