I believe you can set up

var myCheckBoxFactory:ClassFactory = new ClassFactory(CheckBox);
myCheckBoxFactory.properties = { enabled : determineEnabled() };

and then use that instead of just CheckBox as your renderer.

I'm actually working on something similar and what I'd like to know is
if there is a way to have this driven by the data backing each row. That
is, if I have a grid with columns id and isGreat, I'd like something
like

id | isGreat
1  |  \x\
2  |  \ \
3  |  [x]
4  |  [ ]


where this is driven by something like

canSetGreatness(id:Number):Boolean {
   return id == 3 || id == 4;
}

(obviously with more logic in the real check function) and where

where [ ] denotes a checkbox and \ \ denotes a disabled checkbox.

Is this doable?

-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: David C. Moody <[EMAIL PROTECTED]>
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: DataGrid CheckBox Renderer
Date: Thu, 29 May 2008 18:03:37 -0000

Yeah I'm wanting to make it where certain users can't click the 
checkbox. so enabled="false" is what I'm looking for.

Also though, is there a way to catch the click on the checkbox and 
then run a check, then if the check returns true allow the box to be 
clicked and if it returns false alow it not to be clicked.

Thanks,
-David

--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Not sure what you mean by disabled. Do you mean enabled=false or
> non-editable?
> 
> 
> 
> rendererIsEditor should keep the TextInput from popping up.
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
> Behalf Of David C. Moody
> Sent: Thursday, May 29, 2008 10:04 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] DataGrid CheckBox Renderer
> 
> 
> 
> 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