Use a cellrenderer, the cellRenderer API was designed to extends and provide
custom inner layout of datagrid cells.
There are some default objects that decorate each CellRenederer instance:
var listOwner:MovieClip //the datagrid
var getCellIndex:Function
var getDataLabel:Function
var owner:MovieClip //the dataGridColumn instance
These are actually present whether you use a customCellRenderer or not. So
in your case simply use these to listen/dispatch the events you need. Your
Cellrenderer can add events onto these objects or broadcast events out to
the DataGrid as things happen within the CellRenderer.
For example say I have an inner checkbox within my CellRenderer. I would add
a click event onto that control where it would do something like so.
Note: 'com' is my cellRenderers inner component instance:
function click(){
//obtain the index
var index = getCellIndex()
//obtain the columnName from the Datagrid
var colName = listOwner.getColumnAt( index.columnIndex ).columnName
//edit the data because the component data had changed
listOwner.dataProvider.editField( index.itemIndex , colName , com.selected )
//set the dataproviders seletedIndex
listOwner.selectedIndex = index.itemIndex
//trigger a 'celledit' event in the datagrid
listOwner.dispatchEvent( { type:"cellEdit" , cell:this , column:colName,
value:com.selected } )
}
Stump Flexcoders? Think again! :)
Cheers,
Ted ;)
> Well, I found you can simply pass a Function object to the custom
> DataGridCell and have the custom cell handle its own click method with
> that Function. The drawback is that the function must live in the
> same MXML file that the DataGridCell is declared in. I'd still much
> rather use Flex's own event handling mechanisms. Any other ideas?
> Have I stumped the flexcoders?!
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/