Deep Dive Into the Spark Datagrid

POSTED IN Adobe Max, Conferences, Flex | TAGS : , , , , , , , , , , , October 31, 2010

Hans Muller, senior engineer on the Flex framework, is up to talk about the spark Datagrid.  He is the main guy that’s coding the component.  What he’s trying to accomplish is to include very similar features from the MX Datagrid (and AdvancedDatagrid) into this one easily skinnable component.

One of the big themes of the new Flex framework is speed, and this component is no exception.  The component will support virtual layouts which means that a typical Datagrid could have hundreds of thousands of rows and thousands of columns and still work perfectly fine.  However, for now, the scrolling and creation performance isn’t as good, but they’re still working on that part.  For now, they’ve noticed a 10% to 20% increase in performance for the new Datagrid, but still a lot of work left.  It still are missing a lot of features used in the ADG, like grouped columns, drag and drop, locked rows and multi-column sorting.

To increase skinnability, the datagrid is separated in many sections that are individually customizable.  You can now change every part of your grid to make it look exactly like the designer wants it to, something that was extremely hard to do in the MX component.

For better performance, they’ve added new protected functions that you can override and use.  Those functions are ‘prepare’ and ‘discard’.  The prepare function is called for making certain calculations that shouldn’t be included in the updateDisplayList function; essentially separating the drawing logic from the business.  Discard is a function called when the item renderer is about to get garbage collected so that you can remove any event listeners that were added.  There’s also a new property for item renderers named ‘hasBeenRecycled’ which is just a flag to let the developer know when it’s been garbage collected.

While Hans was showing his slides, I noticed that the code displayed was using a lot of vectors instead of the usual ArrayCollection.  This is great news since the ArrayCollection is ridiculously slow compared to vectors.

Lastly, they’ve added new selection flags to enhance the behavior of cells like ‘requireSelection’ and ‘preserveSelection’.  There’s also a new selection mode property that sets different behavior types for the grid (ie. row, area, column, etc).

All of these are already part of the latest build of 4.5 that’s available on labs.

Loading