OK I'm having some trouble with a datagrid checkbox renderer.  I have 
the renderer workign properly.  It updates the dataprovider and 
updates the actual datasource.

My problem is if I want to disable the checkbox, how can I do that?

Here is my flex code:
<mx:DataGrid y="309" height="200" id="cfDetail" left="10" right="25" 
change="updateDetail(event)" editable="true" 
itemEditBeginning="checkUser(event)" itemEditEnd="handleItemEditEnd
(event)">
        <mx:columns>
                <mx:DataGridColumn headerText="Requested Date" 
dataField="req_date" width="115" editable="false"/>
                <mx:DataGridColumn id="detailApproved" 
headerText="Approved" dataField="approved" width="75" 
textAlign="center" editable="false"><!--
itemRenderer="com.coachflex.components.DGCheckBox" />-->
                        <mx:itemRenderer>
                                <mx:Component>
                                        <mx:CheckBox 
selected="{data.approved}" click="data.approved=!
data.approved;outerDocument.updateApproval();" />
                                </mx:Component>
                        </mx:itemRenderer>
                </mx:DataGridColumn>
                <mx:DataGridColumn headerText="Who" dataField="name" 
width="75" editable="false"/>
                <mx:DataGridColumn headerText="Reason" 
dataField="period" editable="true"/>
        </mx:columns>
</mx:DataGrid>

private function checkUser ( event: DataGridEvent ):void {
        var userUpper:String = parentApplication.userSO.data.username;
        var userLower:String = userUpper.toLowerCase();
        userUpper = userUpper.toUpperCase();
        if (event.dataField == "approved") {
                event.preventDefault();
        }
        if (userUpper == cfDetail.dataProvider[event.rowIndex]
['name']) {}
        else if (userLower == cfDetail.dataProvider[event.rowIndex]
['name']) {}
        else {
                event.preventDefault();
        }
}

public function updateApproval():void {
        if (cfDetail.selectedIndex != -1) {
                var row:int = cfDetail.selectedIndex;
                var recnum:String = cfDetail.dataProvider[row]
['recnum'];
                amfRegistry.updateApproved
(recnum,parentApplication.userSO.data.user_id,cfYear.text);
        }
}


All updateApproval does is update the datasource via AMFPHP.  I had 
to make the column as not editable, otherwise when you when to click 
on the checkbox it gave me a textinput area.  It still performed the 
click, but was not the desired effect.  By making the column not 
editable I was able to avoid this effect.

Any help will be greatly appreciated.

-David

Reply via email to