Monday, February 23, 2009

Flex Checkbox as Grid item editor and renderer

I have a dataGrid with a few columns that are simply check boxes. The kicker is I want the user to be able to edit those check boxes. So I knew the first step, using the renderer to have the data from the data provider show up in a check box, but I had to do some research for the editor part.

Here is the code snip of the DataGridColumn that should help you out if you were trying to do that same thing. (Warning: the textAlign property may only work in Flex 3).


<mx:DataGridColumn
dataField="isOpen"
headerText="Open"
editable="true"
textAlign="center"
itemEditor="mx.controls.CheckBox"
editorDataField="selected"
itemRenderer="mx.controls.CheckBox"/>


The important part to this that I was missing is:
editorDataField="selected"

This returns the value of the 'selected' property to the data provider, otherwise, by default it looks to return the "text" property, which a check box does not have.

Hope that helps someone.

Wednesday, February 18, 2009

Flex Advanced Data Grid remove item

This shouldn't have taken me this long to figure this out... it is really quite simple actually.

I have an AdvancedDataGrid with a Hierarchical data provider. I have a delete button. The behavior I want is when the user clicks the delete button whatever row is highlighted (selected) in the ADG is removed.

To do this you need to use two methods.

The first is the removeChild method. Use this on the dataprovider of the ADG. It takes two arguments, the parent node, and the object to be removed. IF you're object is at the top mode, pass null for the parent node argument.

removeChild(parent,object)

The second is the getParentItem method. This method, you guessed it, returns the parent of the item passed to it.

getParentItem(Object);

Use them together to remove the selected item in your ADG.

myADG.dataProvider.removeChild( myADG.dataProvider.getParentItem(myADG.selectedItem), myADG.selectedItem );

Note, make sure your data provider is bound to the ADG.

Monday, February 9, 2009

Flex Advanced Data Grid - header properties to know

I'm working with another advanced data grid. The grid has a lot of columns and fitting it on one screen without a horizontal scroll is proving challenging. Here are a couple properties regarding headers that I found helpful:

sortExpertMode - Setting this property to true removes that little vertical bar next to your header text. That frees up some horizontal space.

headerWordWrap - Setting this property to true allows multi-line headers. You will need to set the Column width to force the text to wrap, and you'll probably need to set the header height since the default isn't tall enough to fit two lines of text.

folderClosedIcon & folderOpenIcon - Setting these properties to {null} will remove the little folder icon next to the grouped item. You can also use these properties to show a custom icon.

Thursday, February 5, 2009

No more ImageReady

Does anyone else find it annoying that ImageReady was discontinued? Right now I am trying to edit an animated gif, which I would always do in ImageReady, but now that it's not there I'm not sure what to do. When I open an animated gif file Photoshop looses all the data so you can only see the first frame (even tho the animation timeline feature was added to Photoshop CS3??? Can I say... WTF?) The solution they're purposing is to open the gif in Fireworks. Oh, that's great... if you HAVE Fireworks. I have the Adobe Design Premium package - and that doesn't include Fireworks. UGH. I can open it in Flash, but the editing tools in Flash suck. Man oh man... sorry for the vent!

Edit...

My solution for this is as follows:

Open the animated gif in Flash. Then export the movie as MOV file. Open Photoshop CS3. Choose File - Import - Video Frames to Layers...

Window - Animation will show you the animation time line frames thingy.

Again, does anyone else find it ridiculous that a program that can create animated gifs can't open them??? Also sorry that my solution requires Flash.

Tuesday, February 3, 2009

Metro SPCA

Thanks to the people at the SPCA for sending me a thank you gift. It feels great to be appreciated. The NS SPCA gave me an honorary membership, a tote bag, and a certificate of appreciation.

Here is what I did for them:
http://www.metro.spcans.ca/