PDA

View Full Version : How does flex figure out what parameter to take in its functions?


cpthk
08-16-2010, 09:25 PM
I have seen some code like this:


<mx:Script>
private function tipFunc(canvas:Canvas):String{
return .....;
}
</mx:Script>

<mx:DataGrid ...
dataTipFunction = "{tipFunc}">
</mx:DataGrid>


I am wondering how does flex figure out I want to pass in "canvas" to the function? How does it know where to look for "canvas"? In the DataGrid declaration, there is no any parameter passed in. What parameters are allowed to pass in like that?

Thanks.

drkstr
08-17-2010, 01:45 AM
According to the documentation (http://livedocs.adobe.com/flex/3/langref/mx/controls/DataGrid.html)...

dataTipFunction property
dataTipFunction:Function
User-supplied function to run on each item to determine its dataTip. By default, the list looks for a property named label on each data provider item and displays it. However, some items do not have a label property nor do they have another property that can be used for displaying in the rows. An example is a data set that has lastName and firstName fields, but you want to display full names. You can supply a dataTipFunction that finds the appropriate fields and return a displayable string. The dataTipFunction is also good for handling formatting and localization.

The dataTipFunction takes a single argument which is the item in the data provider and returns a String:

The default value is null.

This property can be used as the source for data binding. When this property is modified, it dispatches the dataTipFunctionChanged event.



Implementation
public function get dataTipFunction():Function
public function set dataTipFunction(value:Function):void