Posts in Category "Flex"

Sorting Date fields in a DataGrid in the Flex Framework

I was working on some new mini chart apps over the weekend for the MXNA reports section, and had a DataGrid that contained dates. I wanted to allow the user to sort the datagrid by the DateField, but by default the DataGrid sorts dates with a string compare (calling toString on the Date instance).

I tried to set up a custom sort function for the DataGridColumn instance that contained the dates, but because I was using a custom label format function for the column, Flex passed the labels to me, and not the data items (which would allow me to get access to the Date instance). Because of this, I couldn’t sort on the date.

Continue reading…

Subclassing the mx:Application Tag in Flex

Now that there is a Free non-commercial license for Flex, I thought I would spend a little time playing around with it.

I went through this great tutorial by Robert Crooks, and was pretty impressed by how quick it was to put together the simple application. However, one thing felt weird to me, and that was mixing ActionScript in with my MXML. I am used to creating a class for my application controller. Including functions in an include file just felt weird to me (although behind the scenes they do get compiled into a class).

So, I asked around at Macromedia if it was possible for me to subclass the <mx:Application> tag with my custom class, and it turns out it is.

So, here is the modified code for the Coffee Application from Robert Crook’s tutorial. This one uses a custom controller class that extends the Flex Application class.

Continue reading…