You’re going to need to write a cell renderer for the columns where you want the text to turn red.  Watch the property of the object with the checkbox (deleterx) and if it is set turn your color red.

 

Your cell renderer could be something like this maybe:

<mx:Label>

  <mx:Script>

     Function set deleted(d:Boolean):Void

     {

        if (d) setColor(“red”);

        else setColor(“black”);

     }

 

     Var itemObj : Object;

 

     Function setValue(str:String, itemobject, sel:Boolean) : Void

     {

       itemObj =itemobject;

       this.text = str;

     }

  </mx:Script>

 

<mx:Binding source=”itemObj.deleterx” destination=”deleted” />

 

</mx:Label>

 

I haven’t tested any of this but it will hopefully give you some ideas.

 

Matt

 

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of Joe
Sent: Friday, June 17, 2005 11:25 AM
To: [email protected]
Subject: [flexcoders] Cell Rendering with click event

 

I have a data grid that is a component for another page. In one of
the columns in the data grid I am providing a check box. The plan is
for the user to click the check box and have the text in that row
turn red. How to get that event to happen and is the fact that the
data grid is component going to matter or not. I have provided te
code below and suggestions would be great. Thank you.

---- data grid -----

<?xml version="1.0" encoding="utf-8"?>
<mxataGrid xmlns:mx="http://www.macromedia.com/2003/mxml"
rowHeight="35" width="800" height="302"
alternatingRowColors="[#fafafa,#ffffff]" useRollOver="false"
selectable="false" >
<mx:Model id="DXList" source="dxlist.xml"/>
<mxataProvider>{DXList.dxinfo}</mxataProvider>
<mx:columns>
<mx:Array>
<mxataGridColumn headerText="Dx Code" columnName="dxcode"
textAlign="center" width="75" sortable="true" />
<mxataGridColumn headerText="Dx" columnName="dxdesc"
textAlign="center" width="455" sortable="true"/>
<mxataGridColumn headerText="Dx Source" columnName="dxsource"
textAlign="center" width="85" sortable="true"/>
<mxataGridColumn headerText="Delete" columnName="deleterx"
cellRenderer="CheckCellRenderer" textAlign="center" width="55"
sortable="false" />
<mxataGridColumn headerText="Reason" columnName="deletereason"
cellRenderer="reasonlist" textAlign="center" width="90"
sortable="false" />
</mx:Array>
</mx:columns>
</mxataGrid>

---- rendering file -----

//********************************************************************
********
//Copyright (C) 2003 Macromedia, Inc. All Rights Reserved.
//The following is Sample Code and is subject to all restrictions on
//such code as contained in the End User License Agreement
accompanying
//this product.
//********************************************************************
********

import mx.core.UIComponent
import mx.controls.CheckBox

class CheckCellRenderer extends UIComponent
{

var check : MovieClip;
var listOwner : MovieClip; // the reference we receive to the list
var getCellIndex : Function; // the function we receive from the list
var getDataLabel : Function; // the function we receive from the list

function CheckCellRenderer()
{
}

function createChildren(Void) : Void
{
check = createClassObject(CheckBox, "check", 1, {styleName:this,
owner:this});
check.addEventListener("click", this);
size();
}

// note that setSize is implemented by UIComponent and calls size(),
after setting
// __width and __height
function size(Void) : Void
{
check.setSize(20, layoutHeight);
check._x = (layoutWidth-20)/2;
check._y = (layoutHeight-16)/2;
}

function setValue(str:String, itembject, sel:Boolean) : Void
{
check._visible = (item!=undefined);
check.selected = item[getDataLabel()];
}

function getPreferredHeight(Void) : Number
{
return 16;
}

function getPreferredWidth(Void) : Number
{
return 20;
}


function click()
{
listOwner.editField(getCellIndex().itemIndex, getDataLabel(),
check.selected);
}

}







Yahoo! Groups Links

Reply via email to