Hi. I have a quick question about getting the value from control which I added in my data grid by Item render and how can I get that control object when I am clicking on the cell of that column.
A:
you can access by this
<mx:DataGrid id="fileGrid" click="onClick(event)" dataProvider="{grpCollection}" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn dataField="labelText" headerText="" visible="{!readOnly}" width="100">
<mx:itemRenderer>
<mx:Component>
<renderers:LinkRendererWithEvent/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
private function onClick(event:MouseEvent):void
{
if (event.target is LinkRendererWithEvent)
{
var linkRenderer:LinkRendererWithEvent = event.target as LinkRendererWithEvent;
if (linkRenderer.linkBut.label == "Add")
{
}
}
}
LinkRendererWithEvent.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" doubleClickEnabled="true" doubleClick="doubleClickHandler()"
implements="mx.controls.listClasses.IDropInListItemRenderer">
<mx:Script>
<![CDATA[
import mx.controls.Button;
import mx.controls.DataGrid;
import mx.events.FlexEvent;
import com.barcap.customui.constant.NotificationNames;
import com.barcap.customui.ApplicationFacade;
import mx.controls.dataGridClasses.DataGridListData;
import flash.events.Event;
import mx.controls.listClasses.BaseListData;
import mx.controls.dataGridClasses.DataGridListData;
protected var _listData:DataGridListData;
[Bindable]
public var labelField:String;
public var notificationName:String;
override public function setFocus():void
{
trace("called ");
}
private function clickHandler(event:MouseEvent):void
{
dispatchEvent(event);
}
private function doubleClickHandler():void
{
owner.dispatchEvent(new MouseEvent(MouseEvent.DOUBLE_CLICK, false, false));
}
override public function set data(value:Object):void
{
super.data = value;
setIt(value);
}
public function get listData():BaseListData
{
return _listData;
}
public function set listData(value:BaseListData):void
{
_listData = DataGridListData(value);
invalidateProperties();
}
private function setIt(value:Object):void
{
if (value && _listData)
{
linkBut.label = value[_listData.dataField];
}
else
{
linkBut.label = "";
}
}
override public function drawFocus(isFocused:Boolean):void
{
trace("Enter drawFocus");
}
]]>
</mx:Script>
<mx:LinkButton id="linkBut" textDecoration="underline" click="clickHandler(event)"/>
</mx:VBox>
Rahul Garg
2010-02-02 07:10:51
Thanks Rahul Garg
Atul Yadav
2010-02-02 09:57:20
How we get then nex cell control also..Thanks
Atul Yadav
2010-02-03 11:19:23
what is "nex cell control"
Rahul Garg
2010-02-04 01:31:18