Topic
  • 5 replies
  • Latest Post - ‏2012-12-14T00:16:49Z by rtlenaha
Jumbo123
Jumbo123
33 Posts

Pinned topic How to set selected values in a multiselected dropdown in re-entrant coach.

‏2012-07-29T20:11:46Z |
Hello Folks,

I have one service in which i have two coaches. In Coach 1 , i have a multi-selected dropdown which is bound to a variable of string list type and it has also dynamic binding specified in the presentation tab. I have selected 3 options from the multi-dropdown. On submit of coach 1 , i am navigating to Coach 2. Coach 2 has a back button which when clicked will navigate user to Coach 1 where my multi-selected dropdown is present.

The problem is that though i am able to see the values in the variable(while debugging) which is bound to the multi-selected dropdown, the options(which i have chosen before) in the dropdown are not shown as selected.

Is this the default behavior of this control? Please help me how to avoid this problem. Thanks.
KK
Updated on 2012-12-14T00:16:49Z at 2012-12-14T00:16:49Z by rtlenaha
  • Jumbo123
    Jumbo123
    33 Posts

    Re: How to set selected values in a multiselected dropdown in re-entrant coach.

    ‏2012-07-30T06:11:44Z  
    Hi Guys,

    Any Idea here how to resolve the problem.

    Thanks,
    KK
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: How to set selected values in a multiselected dropdown in re-entrant coach.

    ‏2012-07-30T14:28:03Z  
    • Jumbo123
    • ‏2012-07-30T06:11:44Z
    Hi Guys,

    Any Idea here how to resolve the problem.

    Thanks,
    KK
    If I remeber correctly, assuming the drop down list is being populated by a List of (some complex type) on the server, prior to going to the coach, just use JS to set list selected on each of the selected items.

    Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
  • Jumbo123
    Jumbo123
    33 Posts

    Re: How to set selected values in a multiselected dropdown in re-entrant coach.

    ‏2012-07-30T18:44:11Z  
    If I remeber correctly, assuming the drop down list is being populated by a List of (some complex type) on the server, prior to going to the coach, just use JS to set list selected on each of the selected items.

    Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
    Hi Andrew,

    Could you please let me know how can i do this before coach loading?

    Here is what i am doing in the coach inside a custom html component.

    <script>
    function showSelectedValues(){
    <#
    • var selectedValues = tw.local.test;*
    • *
    • for (var idx2 = 0; idx2 < selectedValues.listLength; idx2++) { #>*

    • selectValue(document.getElementById("InputText0"), '<#= selectedValuesidx2 #>');*
    <#
    • }*
    #>
    }

    addOnPageLoadFunction(showSelectedValues);

    </script>
    But i am not getting the desired result.
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: How to set selected values in a multiselected dropdown in re-entrant coach.

    ‏2012-07-31T16:43:25Z  
    • Jumbo123
    • ‏2012-07-30T18:44:11Z
    Hi Andrew,

    Could you please let me know how can i do this before coach loading?

    Here is what i am doing in the coach inside a custom html component.

    <script>
    function showSelectedValues(){
    <#
    • var selectedValues = tw.local.test;*
    • *
    • for (var idx2 = 0; idx2 < selectedValues.listLength; idx2++) { #>*

    • selectValue(document.getElementById("InputText0"), '<#= selectedValuesidx2 #>');*
    <#
    • }*
    #>
    }

    addOnPageLoadFunction(showSelectedValues);

    </script>
    But i am not getting the desired result.
    You need to drag in a server side script component and route to it before rendering the coach. The code will be something like this -

    
    
    
    for(selectedCount=0; tw.local.selectedValues != 
    
    null && selectedCount<tw.local.selectedValues.length; selectedCount++)
    { currentValue =tw.local.selectedValues[listCount]; found=
    
    false 
    
    for(allCount =0; allCount < tw.local.possibleValues.length && !found; allCount++)
    { 
    
    if(tw.local.possibleValues[allCount]==currentValue)
    { found=
    
    true; tw.local.possibleValues.listAddSelected(allCount) 
    } 
    } 
    }
    


    (This is off the top of my head, your actual implementation may need to be different.)

    Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
  • rtlenaha
    rtlenaha
    60 Posts

    Re: How to set selected values in a multiselected dropdown in re-entrant coach.

    ‏2012-12-14T00:16:49Z  
    I am curious as to whether you found a solution to this problem. We have a similar issue where we show a user a list of items that belong to him/her. Upon entry into the coach, they are unable to edit - but if they select the 'edit' button, we retrieve possible values for them to select (rather than allowing free-form typing entry) - but with their INITIAL value showing as a default to keep the user from being confused. Right now, since we are binding to a list variable, those values are showing in alphabetical order rather than dislaying the original value.

    We are using IBM WLE 7.5.1.1.