Alpha Video Training
Results 1 to 3 of 3

Thread: Multi-select button list values are in reverse order

  1. #1
    Member
    Real Name
    Richard
    Join Date
    Mar 2012
    Posts
    350

    Default Multi-select button list values are in reverse order

    I have added a standard button list control to a UX.
    It has 18 buttons defined and each button returns the same value as its name, eg button 1 returns 1, button 2 returns 2 etc.
    The button list allows multiple selections.

    When I get the value of the button list it returns comma separated values but they are in reverse order, eg if buttons 1, 3, and 9 are selected the return value is 9,3,1

    This seems a bit strange and there doesn't appear to be a property to control this. Any ideas or help with javascript to reverse the order is appreciated.

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,541

    Default Re: Multi-select button list values are in reverse order

    This is another head shaker. If you're using .getValue, then what you get is a weird array... with 1 value, items backward. Using .getValue your return is actually ["9,3,1"]. Why it's backwards... who knows. Why it's an array... but isn't an array you can easily use... who knows. It's essential an array with one value... a comma delimited list of the buttons you've selected. Buy why put it into an array... if it's not going to be an array of values?? Anyway...

    Instead of using .getValue()... use .getControl(). This will let you get a true array of values (that's the head shaking part). The array is there... it's just that Alpha doesn't give it to you with .getValue().

    Once you have the array (still backwards) you can reverse it. I would hope that Alpha is using Javascript .push() to add to the array... but .push() always adds to the end of the array... so ???

    Here's another mystery... no matter what order you select your buttons in, they will always only be easily available from highest to lowest order... and not of the button values you selected, but of the UI button order... which is really weird. E.g. if you select buttons 3,1,9... you will always get ["9,3,1"]... even if you use .getControl(). Alpha is doing a lot of work to give you this result... which doesn't seem to make any sense.

    You can do this to get the buttons in ascending order...

    Code:
    var btnListCtrl = {dialog.Object}.getControl('buttonListManyButtons');
    var blValues = btnListCtrl.value;
    blValues.reverse();

    If you want the values of the buttons you select to be in the order that you select them... there's more work to be done.

    Code:
    var btnOrder = [];
    var btnListCtrl = {dialog.Object}.getControl('buttonListManyButtons');
    var blSel = btnListCtrl.selection;
    var btns = btnListCtrl._btns;
    for(var i=0;i<blSel.length;i++){
    	btnOrder.push(btns[blSel[i]].value);
    }
    Set up an array
    Get the button list control
    Use the button list control property ".selection" to get the zero based values of the buttons selected... in their proper order
    Loop through the button list control buttons picking out the values based on the .selection property
    Push these values into an array

    Overall, the button list control seems a bit unpolished.

  3. #3
    Member
    Real Name
    Richard
    Join Date
    Mar 2012
    Posts
    350

    Default Re: Multi-select button list values are in reverse order

    Thanks David,

    I borrowed from your examples and ended up doing this to reverse the returned value of the button list. In my case it didn't matter what order they were pressed in.

    var btnListCtrl = {dialog.Object}.getValue('MYBTNLIST');
    var blValues = btnListCtrl.toString();

    var blValuesReversed = reverseCommaSepString(blValues); //call function below

    function reverseCommaSepString(str) {
    return str.split(",").reverse().join(",");
    }

Similar Threads

  1. Make list multi-select or single select dynamically
    By mikeallenbrown in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 08-31-2015, 06:08 PM
  2. Multi-select list box not showing retrieved values
    By Anita Headley in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 02-25-2014, 09:51 PM
  3. Select all items in multi-select list box by default
    By Jay Talbott in forum Alpha Five Version 8
    Replies: 10
    Last Post: 02-02-2012, 06:27 PM
  4. Set Default Values in an Xdialog Multi Select Checkbox List
    By johngtatp in forum Alpha Five Version 10 - Desktop Applications
    Replies: 13
    Last Post: 02-02-2012, 04:07 PM
  5. Embedded Multi-Select Check box list To Filter another checkbox list
    By aaronhaul in forum Alpha Five Version 10 - Desktop Applications
    Replies: 2
    Last Post: 01-10-2012, 03:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •