2 Replies Latest reply on Dec 17, 2008 6:31 AM by robbyzz

    Mod editable property on DataGrid

    robbyzz
      I have a DataGrid and with a button I need to change DataGrid editable into true or false.
      My DataGrid has id="UsersList". I tried with
      ........
      <mx:Script>
      <![CDATA[
      private function change_status():void {
      UsersList.editable=true;
      }
      ]]>
      </mx:Script>
      .............
      .............
      <mx:Button x="151.5" y="320" label="Mod" click="change_status()"/>
      ............

      but not work....is it possible to change dinamically this property with a button ?
        • 1. Re: Mod editable property on DataGrid
          amol bhandwale Level 1
          this is possible to change the editable property of datagrid.
          but u can edit the existing rows in the datagrid only not the new row.
          u hve to give dataprovider to datagrid.

          may be this helps u
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top"
          horizontalAlign="center" backgroundGradientColors="[0x000000,0x323232]" paddingTop="0" viewSourceURL="srcview/index.html">

          <mx:XMLList id="employees">
          <employee>
          <name>Christina Coenraets</name>
          <phone>555-219-2270</phone>
          <email>ccoenraets@fictitious.com</email>
          <active>true</active>
          <image>images/arrow_icon_sm.png</image>
          </employee>
          <employee>
          <name>Joanne Wall</name>
          <phone>555-219-2012</phone>
          <email>jwall@fictitious.com</email>
          <active>true</active>
          </employee>
          </mx:XMLList>
          <mx:Script>
          <![CDATA[
          public function change():void{
          dg.editable = true;
          }
          public function change1():void{
          dg.editable = false;
          }
          ]]>
          </mx:Script>
          <mx:Panel title="DataGrid Control" layout="vertical" color="0xffffff" borderAlpha="0.15" width="500"
          paddingTop="5" paddingRight="10" paddingBottom="10" paddingLeft="10" horizontalAlign="center">
          <mx:Label width="100%" color="0x323232"
          text="Select a row in the DataGrid control."/>
          <mx:DataGrid id="dg" color="0x323232" width="100%" rowCount="3" dataProvider="{employees}">
          <mx:columns>
          <mx:DataGridColumn dataField="name" headerText="Name"/>
          <mx:DataGridColumn dataField="phone" headerText="Phone"/>
          <mx:DataGridColumn dataField="email" headerText="Email"/>
          </mx:columns>
          </mx:DataGrid>
          <mx:Button click="change()" label="true" color="#000000"/>
          <mx:Button click="change1()" label="false" color="#000000"/>
          </mx:Panel>
          </mx:Application>

          Amol

          • 2. Re: Mod editable property on DataGrid
            robbyzz Level 1
            Thank you, now it works correctly. :-)