DropDownList as renderer, how to pre-select an item in the DropDownList control?

People in the original documents have given height stored as 1, 2, 3

1 = tall

2 = medium

3 = short

DropDownList in the DataGrid displays the height in option name.  The requirement is when the page is loaded for the first time, control DropDownList for each record must indicate the original data of the height. How to do?

Thanks for all the ideas.

<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the MXDataGridItemRenderer control -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"    
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx">
    
    <fx:Declarations> 
        <!-- Data provider for the DataGrid -->
        <s:ArrayCollection id="dp1">
            <fx:Object firstName="Alex" enumValue="1"/>
            <fx:Object firstName="Britanny" enumValue="2"/>
            <fx:Object firstName="Charlie" enumValue="3"/>
            <fx:Object firstName="Douglas" enumValue="1"/>
            <fx:Object firstName="Eric" enumValue="2"/>
            <fx:Object firstName="Frank" enumValue="2"/>
        </s:ArrayCollection>        
    </fx:Declarations>
    
    <s:Panel width="75%" height="75%" title="MXDataGridItemRenderer Example" horizontalCenter="0" verticalCenter="0">
        <!-- Halo DataGrid -->
        <mx:DataGrid id="dg1" height="200" width="300" editable="true" dataProvider="{dp1}">
            <mx:columns>            
                <!-- Column 1 -->
                <mx:DataGridColumn dataField="firstName" headerText="Name" />
                <!-- Column 2 -->
                <!-- itemRenderer used as the itemEditor via rendererIsEditor flag -->
                <mx:DataGridColumn dataField="enumValue" headerText="Size" editorDataField="editValue" rendererIsEditor="true">
                    <mx:itemRenderer>
                        <fx:Component>                            
                            <s:MXDataGridItemRenderer height="22" >     
                                <!-- function to set the value selected by the user -->
                                <fx:Script>
                                    <![CDATA[                                
                                        public function get editValue():* {
                                            return ddl.selectedItem;
                                        }
                                    ]]>
                                </fx:Script>
                                <!-- DropDownList used as renderer and itemEditor -->
                                <s:DropDownList id="ddl" width="100%" height="100%" labelField="HeightName" selectedItem="{data.enumValue}">
                                    <s:dataProvider>
                                        <s:ArrayList>
                                            <fx:Object HeightID="1" HeightName="Tall" />
                                            <fx:Object HeightID="2" HeightName="Medium" />
                                            <fx:Object HeightID="3" HeightName="Short" />
                                        </s:ArrayList>
                                    </s:dataProvider>
                                </s:DropDownList>
                            </s:MXDataGridItemRenderer>
                        </fx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>                 
            </mx:columns>
        </mx:DataGrid>    
    </s:Panel>          
</s:Application>

Hi Alex,

Please find the code to work for your problem. I did it in Flex3... but you can do even in Flex4.

Since it is just a function in your script. Check out the code below:


http://www.Adobe.com/2006/mxml">
   
                         
]]>
   


       
       
       
       
       
       
   
  
       
   
paddingTop = "10" paddingLeft = "10" paddingRight = "10" paddingBottom = "10" >
       
        
         
         
          
                                    
            
             
                 
                     
                     
                     
                 

             

             
              Import mx.collections.ArrayCollection;
              
private function setDDLSelectedItem (): void
{
var ddlDP:ArrayCollection = this.dataProvider as ArrayCollection collection;
for (var intLoop:int = 0; intLoop<>
{
var v1:int = data.enumValue;
var v2:int = ddlDP.getItemAt (intLoop). HeightID
                
If (data.enumValue is ddlDP.getItemAt (intLoop). HeightID)
{
this.selectedIndex = intLoop;
break;
}
}
}
]]>
            

         

           

          

         

        

       

   

If this post answers your question or assistance, please mark it as such.

Thank you

Jean Claude Chari

Tags: Flex

Similar Questions

  • How to pre-select an item in a drop-down list

    Hello

    I need to pre-select an item in a drop-down list, but I don't see how to achieve this using the current or existing methods.  I know that if I set the rawValue then it works, but later when I try to retrieve the data in the selected drop-down list the order of the day list, I get an 'empty' which does not help.  What he needs, is the value, the pair of label to work properly. When I manually select an item in the drop-down list, it works perfectly. But not when I try programtically set. So now I wonder if it is possible to set the index for the drop-down menu, so that he believes have a selected item, when I survey I get the correct value.

    Hope you can help.

    Kind regards

    Ian

    Hello

    You can use the selectedIndex property to set the desired value.

    And to retrieve a value, I recommend you to use *.getDisplayItem (*.selectedIndex);

    I hope this will help you!

  • How can I select multiple items in the list of the spark without pressing the command?

    Hi all

    I need to change the behavioral list to allow multiple selections by clicking on each item

    In the list, instead of using the control

    30:

    Elazar r

    This blog explains how: http://flexponential.com/2009/12/13/multiple-selection-in-a-spark-list-without-the-control - key /

  • How can I remove an item in the impression that who refuse to cancel?

    How can I remove an item in the impression that who refuse to cancel? It keeps me to print anything else.

    Hello

    I think that you need to remove the tail. For Windows, try it please:

    • Hold down the Windows key and press R.
    • from the run window, type services.msc and press to enter.
    • If the computer asks you to Admin, you have to accept that,
    • regarder watch down to the print spooler service, right-click and select Properties
    • Click the Stop button,
    • Go to C:\Windows\System32\Spool\printers
    • delete the job inside this folder
    • restart the machine.

    Kind regards.

  • Header download for the 'sent items' folder did not complete. Cannot select "Sent items" on the IMAP server. Error number: 0x800CCCD2

    original title: error number: 0x800CCCD2

    Can anyone help with this issue:

    Header download for the 'sent items' folder did not complete. Cannot select "Sent items" on the IMAP server. You could try refreshing your folder list to synchronize with the IMAP server. Account: 'AOL', server: 'imap.aol.com', Protocol: IMAP, server response: "SELECT failed", Port: 143, secure (SSL): no, error number: 0x800CCCD2

    Thank you!

    Hi again Steve - I have spent a lot of time on the phone this morning to Dell technical support. the accompaniment of the victim and I did a lot of fiddling around with various options of Windows Mail and I don't know exactly what we were doing, but the issue seems to have resolved itself! Thank you for your time and trouble.

    Best, Douglas

  • "Unable to select"Sent items"on the IMAP server.

    I am trying to set up Windows Live Mail, but when I send a message, I get the error message "Cannot send or receive messages on behalf of Aol."  Header for the "sent items" download did not complete.  Cannot select "Sent items" on the IMAP server.  Try to update the list of folders, and then try again. "I can't understand what they mean on the"folder list ".  What should I do?  Thank you.

    Thank you for visiting the Microsoft Answers site.

     
    The question you have posted is related to Windows Live Mail and would be better suited to the Windows Live community. Please visit the link below to find a community that will support what ask you:
     
    http://windowslivehelp.com/product.aspx?ProductID=15
  • Impossible to select multiple items in the list box

    I use Acrobat 9.0 Standard.

    I added a list box in the PDF format and I want to give people the ability to select multiple items in the drop-down list. In properties, on the Options tab, I chose 'multiple choice '. But I am unable to make multiple selections despite this. It still only allows me to make a choice.

    Any ideas? Is there some other step I'm missing?

    I need help with this ASAP for my business - any suggestions are appreciated!

    Thank you

    It should do that if you hold down the SHIFT key.

  • How can I create a query with the data control to the web service?

    I need to create a query with the order of web service data, WSDL, it is query operation, there is a message of parameter with possible query criteria and a return message contains the results. I googled but can't find anything on the query with the web service. I can't find a criterion "named" to the data control of web service as normal data control. Blog of Shay, I saw the topics on the update with the data of web service command. How can I create a query with the data control to the web service? Thank you.

    Hello

    This might help

    * 054.     Search form using control data WS ADF and complex of entry types *.

    http://www.Oracle.com/technetwork/developer-tools/ADF/learnmore/index-101235.html

  • How can I select multiple messages at the same time for archiving

    I want to archive multiple messages in a folder from archive. How can I select multiple messages at once?

    To select a block of eg: 10 emails.

    • Click on the first email
    • Hold down the SHIFT key and click the last email.
    • This will highlight all in the interval

    To hightlight all the emails in a folder.

    • Click on the first email to focus.
    • Press on and hold down the 'Ctrl' key and press 'A '.
    • This will highlight all emails.

    To select several emails:

    • Press and hold down the 'Ctrl' key and then use the mouse to select multiple e-mails
    • they will appear as "conversations in the messages pane.
    • Click on archives.

    Info on setting up your archive' Options ': '.

  • How can I remove an item from the death of the select icons and notifications appear in the taskbar?

    When I open "Select icons and notifications appear in the task bar" one of the things it lists is "GLBD565.tmp" which seems to be left by the installation of a software product.  The icon is not active and I doubt if it still exists, but it appears in the list.  That list is maintained and how to remove the dead of her spots?

    The entries to Customize Notifications cannot be removed selectively. You can, however, clear the set lists by using the following registry change.

    1. Click Start, type regedit in the Search box and press ENTER.

    2. Locate and then click the following registry subkey:
      Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify HKEY_CURRENT_USER
    3. In the Details pane, click the IconStreams registry entry.
    4. On the Edit menu, click delete, and then click Yes.
    5. In the Details pane, click the PastIconsStream registry entry.
    6. On the Edit menu, click delete, and then click Yes.
    7. Exit Registry Editor.
    8. Restart the Explorer.exe process. To do this, follow these steps:
    9. Press CTRL + SHIFT + ESC.
    10. On the process in the Task Manager tab, click the process explorer.exe and then double click on end process .
    11. On the file menu, click new task (run), type Explorer and click OK.
    12. Exit Task Manager.

    (c) Microsoft Corporation

    -or-

    Download and run a VBScript script that automates the steps above.
    How to delete items from the Notification area in Windows 7/Vista/XP

    Ramesh Srinivasan, Microsoft MVP [Windows Desktop Experience]

  • How to select multiple items in the Panel of DOM? I tried to use the SHIFT key, but it doesn't seem to work.

    I need help, select several items in my Panel of DOM, for some reason, using the SHIFT key does not work.

    I found the answer, apparently everything I had to do has been updated to the latest version of dreamweaver cc 2015.2. The Shift function is something new added in the update.

  • How can I remove an item in the toolbar that I added

    I added a few items in my toolbar and now I want to delete them, but I can't figure out how to do this. My mouse doesn't have a left and right button

    On Mac, you might be able to simulate a "right-click" holding the key Ctrl key while clicking. In other cases a long-press can simulate a right-click.

    If none of those that suits you, you can use the Customize and drag the items on the toolbar on the menu or in the box with the other unused icons. This article should help you get started: Customize Firefox commands, buttons, and toolbars.

    If one of these methods work for you?

  • Error code: How can I get an item in the Recycle Bin?

    I can't put a webarchive into the trash.  Error message says, "the operation cannot be completed because one or more required elements was not found (error code - 43) how can I get the item in the Recycle Bin?

    reset

    then try again.

  • How to add and remove items in the bookmarks toolbar?

    I want to remove items in the bookmarks toolbar and add those that I use on a regular basis. How can I do this?

    There actually Ctrl-click - sorry for the confusion, I don't use a mac myself...

    http://www.WikiHow.com/right-click-on-a-Mac

  • How can I rename an item in the jumplist

    I create a bookmark for example www.digitec.ch. Firefox offers me as name "digitec online shop. I have change the name to "Digitec" and store the bookmark. Now, I drag the bookmark to "Firefox" in the taskbar and it appears in the jumplist as'https://www.digitec.ch/Startseite.aspx'. How can I rename this point in the jumplist for a reasonable name like "Digitec"?

    I found the solution: first drag the bookmark on the Windows desktop, and from there to the task of Firefox in the Windows task list. In this case the name of the link on the windows desktop is taken.

Maybe you are looking for