1 Reply Latest reply on May 25, 2007 3:04 PM by Tariq Ahmed [ACP]

    Making individual row or cell editable or readonly depend on cell data

    fancycarp
      Dear expert

      I'm working with dataGrid and itemEditor. I can make some column editable. But I would like to know how to set some specific row or cell editable or readonly depend on cell data. Could anybody guide me which method should I override or any idea?

      Thanks
        • 1. Re: Making individual row or cell editable or readonly depend on cell data
          Tariq Ahmed [ACP] Level 1
          Well a simply way would be if the row contained some kind of data that had the info to determine if it was editable or not... e.g. say the data in the dataProvider of the dataGrid has a field called jobTitle and you didn't want cells in that row editable when the jobTitle is "Executive".

          <mx:DataGrid dataProvider="{jobData}" editable="true">
          <mx:columns>
          <mx:Array>
          <mx:DataGridColumn headerText="Title" dataField="Title" itemEditor="titleEditor"/>
          <mx:DataGridColumn headerText="Phone" dataField="Phone" itemEditor="phoneEditor"/>
          </mx:columns>
          </mx:DataGrid>

          Your itemEditor's could check to see if thats the case.

          phoneEditor.mxml
          ##############
          <?xml version="1.0"?>
          <mx:TextInput xmlns:mx=" http://www.adobe.com/2006/mxml" text="{data.Phone}" creationComplete="checkIfEditable()" >
          <mx:Script>
          public function checkIfEditable():void
          if(data.Title == 'Executive') this.editable=false;
          </mx:TextInput>