1 Reply Latest reply on Aug 4, 2009 9:30 PM by Gregory Lafrance

    Enable a button when we select any items in a Datagrid

    hclselvs Level 1



      I would like to enable a button(which will be disabled by dfefault) on a condition basis. i.e., we will have a datagrid on top of the button controls, if any record is selected in a datagrid, these buttons should get enabled.


      Could anyone help to achieve this?

        • 1. Re: Enable a button when we select any items in a Datagrid
          Gregory Lafrance Level 6

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


          Here you are:


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
                import mx.collections.ArrayCollection;
                [Bindable] private var itemSelected:Boolean = false;
                [Bindable] private var ac:ArrayCollection = new ArrayCollection([
                  {col1: "test1_1", col2: "test1_2", col3: "test1_3"},
                  {col1: "test2_1", col2: "test2_2", col3: "test2_3"},
                  {col1: "test3_1", col2: "test3_2", col3: "test3_3"}
            <mx:DataGrid id="dg" dataProvider="{ac}" rowCount="3"
                <mx:DataGridColumn dataField="col1"/>
                <mx:DataGridColumn dataField="col2"/>
                <mx:DataGridColumn dataField="col3"/>
              <mx:Button label="One" enabled="{itemSelected}"/>
              <mx:Button label="Two" enabled="{itemSelected}"/>
              <mx:Button label="Three" enabled="{itemSelected}"/>
            <mx:Text text="DataGrid 'selectedIndex': {dg.selectedIndex}"/>