Monday, January 28, 2008

Pondering on AJAX and Flex

After working with Flex and AJAX for some time I feel like looking back and asking myself when I should use what. My opinion is this:

I think AJAX, more specifically yui, can be used for most of the web-applications. It is simpler to use and written pretty well.

However if we need controls with interactive graphics/charting data or we have a very big and complex application, flex would be a better option.

Lets face it, flex is more powerful and easy to develop (and maintain) of the two. However it has its learning curve and people with good flex skills & strong programming basics are not that easy to find. If your application is indeed that complex and demands a high degree of interaction and/or analytics, flex is a wise decision. Else it is like using a hammer to kill a fly. It is good but you dont have to use it if you dont need it :).

DataGrid Rendering

The default editing control for an editable column is a text field. It is possible to specify the editor via itemEditor attribute and editorDataField. Following controls can be specified:

Button, Label, CheckBox, NumericStepper, ComboBox, Text, DateField, TextArea, Image, TextInput

You can also specify your own control as long as it implements IDropInListItemRenderer interface in its class definition

Item renderers can be used to customize looks of individual columns.

One way is to make a custom renderer (say using Canvas) as an MXML component and giving the appropriate DataGridColumn the full-qualified path to itemRenderer property. Remember that the data property will help you in the renderer to access row data.

Another way is using
tag. Efficient but not modular. Inside the renderer tag you will have to place tag. What is inside this tag will have its own scope, will need its own imports. You can talk to the containing app using outerDocument scope. But the properties you wish to access have to be public.

labelFunction signature for DataGrids is:

labelFunctionName(item:Object,dataField:DataGridColumn)