[Flex] One labelfunction for multiple datagridcolumns

On March 27, 2007, Flash / Flex - 2 Comments

The labelfunction of a listbased component is nice, but a bit limited.
For instance, you have to specify the (data)fieldname inside the function, which makes it impossible to use it for other columns. Wouldn’t it be nice if you could write one labelfunction for all your columns? I thought it would.

In order to accomplish this, I needed to have the columndata inside the labelFunction. At first, I was thinking of extending the labelFunction, but that wouldn’t help me much, because Flex was still sending only the original data and not the columndata. So I went deeper in the component, searching for the function responsible for calling the labelFunction.

more…

[Flex] Really disable disabled items

On February 15, 2007, Flash / Flex - No Comments

I recently discoverd another bug in Flex 2.0.1 / ActionScript 3.0. You cannot trust the enabled property of some components. Especially listbased components like datagrids. When you set the enabled property of a datagrid to false, it still responses to doubleclicks and happily fires it’s events. Probably not what you want. The solution is fairly simple though:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"  >
	<mx:DataGrid
		id="contentitemGrid"
		doubleClickEnabled="true"
		mouseChildren="{contentitemGrid.enabled}" />
</mx:Canvas>

By disabling it’s mouseChildren property, the clickevents of the datagrids children (the items) aren’t fired anymore, so the doubleclick is ignored.