Using a DataGrid control as a pop up in the Flex PopUpButton control

by Peter deHaan on February 1, 2008

in DataGrid, PopUpButton

The following example shows you how you can use a DataGrid control as a pop up in a PopUpButton control in Flex.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/01/using-a-datagrid-control-as-a-pop-up-in-the-flex-popupbutton-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white">

    <mx:Style>
        PopUpButton {
            popUpStyleName: myCustomPopUpStyleName;
        }

        .myCustomPopUpStyleName {
            fontWeight: normal;
            textAlign: left;
        }
    </mx:Style>

    <mx:Array id="arr">
        <mx:Object label="Alert" packageName="mx.controls" />
        <mx:Object label="Button" packageName="mx.controls" />
        <mx:Object label="ButtonBar" packageName="mx.controls" />
        <mx:Object label="CheckBox" packageName="mx.controls" />
        <mx:Object label="ColorPicker" packageName="mx.controls" />
    </mx:Array>

    <mx:PopUpButton id="popUpButton"
            label="Click to open..."
            openAlways="true">
        <mx:popUp>
            <mx:DataGrid dataProvider="{arr}"
                    draggableColumns="false"
                    rowCount="4"
                    width="300">
                <mx:columns>
                    <mx:DataGridColumn dataField="label"
                            headerText="Label:" />
                    <mx:DataGridColumn dataField="packageName"
                            headerText="Package name:" />
                </mx:columns>
            </mx:DataGrid>
        </mx:popUp>
    </mx:PopUpButton>

</mx:Application>

View source is enabled in the following example.

{ 2 comments… read them below or add one }

1 paul mathew March 11, 2008 at 11:57 pm

i want to know how we can use PopUpButton in a datagrid column

Reply

2 Xyrer March 26, 2008 at 8:06 am

This saved my life, I only need to pass the selected data to my php and it’s done, beautiful solution. thanks, keep up, I will definitely subscribe to your blog.

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: