5 Replies Latest reply on Mar 24, 2011 10:44 PM by Flex harUI

    DataGridColumn editable false?

    snkd Level 1

      how to dinamically make editable false for datagridColumn ?

       

      my code is like that

       

      <mx:DataGridColumn

      dataField="dispatch" 

      headerText="Dispatch"

      resizable="false"

      sortable="false"

      editorDataField="selected"

      rendererIsEditor="true"

      itemRenderer="mx.controls.CheckBox"

      >
      </mx:DataGridColumn>

       

      when I always try to set editable false for column.but it never became as I need.Any Ideas?

        • 1. Re: DataGridColumn editable false?
          snkd Level 1

          here is the sample

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <!--Project :UserLevel~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
          <!--File     :TestGrid.mxml~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
          <!--Date    :Mar 24, 2011~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
          <!--Author     :Administrator~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
          <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" minWidth="955" minHeight="600">

           

          <fx:Script>
          <![CDATA[
          import mx.collections.ArrayCollection;

           

          [Bindable]
          private var acDao:ArrayCollection=new ArrayCollection();

           

          protected function button1_clickHandler(event:MouseEvent):void
          {
          acDao.addItem({col1:1,col2:2,col3:true});
          acDao.addItem({col1:11,col2:22,col3:false});
          acDao.addItem({col1:12,col2:23,col3:true});
          acDao.addItem({col1:13,col2:24,col3:false});
          }

           

          protected function button2_clickHandler(event:MouseEvent):void
          {
          for each(var temp:Object in dgDao.dataProvider as ArrayCollection)
          {
          trace("first :"+temp["col1"]+"second :"+temp["col2"]+"third :"+temp["col3"]);
          }
          }

           

          ]]>
          </fx:Script>

           

          <fx:Declarations>
          <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>  

           

          <!--Visual Components Here~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->   
          <mx:DataGrid x="300" y="194" id="dgDao" dataProvider="{acDao}" editable="true">
          <mx:columns>
          <mx:DataGridColumn headerText="Column 1" dataField="col1"/>
          <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
          <mx:DataGridColumn headerText="CheckBox" dataField="col3" editable="true" itemRenderer="mx.controls.CheckBox" editorDataField="selected" rendererIsEditor="true"/>
          </mx:columns>
          </mx:DataGrid>
          <s:Button x="300" y="150" label="Load" click="button1_clickHandler(event)"/>
          <s:Button x="383" y="150" label="view" click="button2_clickHandler(event)"/>

           


          </s:Application>

           

          How can I make the checkbox column editable false dinamically?

          • 2. Re: DataGridColumn editable false?
            EvyatarBH Level 3

            What if you change the rendererIsEditor property to false and add editable="false"?

             

            Another option would be to make the checkbox's click event handler call event.preventDefault()

            • 3. Re: DataGridColumn editable false?
              Flex harUI Adobe Employee

              What code are you using to set it to false?

              • 4. Re: DataGridColumn editable false?
                snkd Level 1

                yes alex,I am using Id for DataGridColumn and try to set editable false for paticular column.

                • 5. Re: DataGridColumn editable false?
                  Flex harUI Adobe Employee

                  That's not code, that's a description.  Post a 20-line test case showing the

                  problem.