Skip navigation
Currently Being Moderated

Advanced DataGrid and CheckBoxes.. how to enable/disable dynamically

Apr 8, 2009 10:18 PM

I have an advanced data grid.  I'm using a checkbox as an itemRenderer in one column.  I want to be able to enable or disable the ability to edit the check box, based on the user's role which is not known until the login process completes.

 

If name the column and do a myColumn.enabled = false, the check box can still be check or unchecked by the user.   This appears to be some sort of 'it is already rendered' problem or something.

 

 

<mx:AdvancedDataGrid dataProvider="{myData}"  itemClick="myDG_itemClick(event)"  id="adgMyGrid">
        <mx:columns>

            <mx:AdvancedDataGridColumn width="10" id="adgColumn" editable="false" visible="true"  sortable="false"   dataField="myData" itemRenderer="mx.controls.CheckBox" />  
        </mx:columns>
    </mx:AdvancedDataGrid>

 

Using the above, I would assume that the adgColumn should not be editable.  But it remains editable, no matter if I try to set it in code or in the declaration.  What am doing wrong?

 
Replies
  • Currently Being Moderated
    Apr 8, 2009 10:53 PM   in reply to jonpor

    The column's editable property specifies whether or not the grid should switch from that column's itemRenderer to the itemEditor when a cell in that column gets focus.  The problem lies in that you're using an editable control as the itemRenderer instead of the itemEditor.  If you want the checkbox look for your renderer, just disabled you can do something like this:

     

    <mx:AdvancedDataGrid dataProvider="{myData}"  itemClick="myDG_itemClick(event)"  id="adgMyGrid">
         <mx:columns>
              <mx:AdvancedDataGridColumn width="10" id="adgColumn" editable="false" visible="true"  sortable="false"   dataField="myData" itemEditor="mx.controls.CheckBox">
                   <itemRenderer>
                        <mx:Component>
                             <mx:CheckBox enabled="false"/>
                        </mx:Component>
                   </itemRenderer>
              </mx:AdvancedDataGridColumn>
         </mx:columns>
    </mx:AdvancedDataGrid>
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2009 6:59 AM   in reply to jonpor

    You need to have a data field that specifies whether or not user should be able to change the state of the CheckBox. So upon login, modify the ADG data provider. And reference the data provider field for the CheckBox enabled field.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points