Recently in General Category

Faster DataGrid Horizontal Scrolling

| 23 Comments

Lately, I've heard many complaints about horizontal scrolling performance in DataGrid. Vertical scrolling has been optimized, but horizontal has not. I found a bit of time to put together how to subclass DataGrid and try to optimize horizontal scrolling. I'm sure there's bugs and I don't know if I'll have time to fix them and the usual caveats apply.

Hope it helps. It should work with any Flex 3 SDK version.

Download Source

In the example, the top DataGrid is not optimized, the bottom one is. Make the screen bigger and you'll start to see and feel the difference.

Run Example

Flex Authority Magazine

| 3 Comments

I think I can finally say I got something published! Gordon Smith and I contributed to the first issue of Flex Authority, a new magazine (made of actual paper!) that focuses on Flex and AIR. We hope to be regular contributors. The link to find out more is: http://www.flex-authority.com/. Buy your subscription today. We won't make any money from it, but this post is to thank them for working with us and to help them get the word out so they can make some money.

Custom ArrayCollections, Adding New Items to DataGrid

| 6 Comments

The previous posts used custom ILists to merge or concatenate other ILists. This example uses a custom subclass of ArrayCollection to fake an empty object at the end of the actual ArrayCollection which can be used to add new entries to the DataGrid.

If the user fills out the new entry, it is added to the actual collection and another new entry is faked. Additional logic dictates that if the user strips all information out of an entry, that entry is removed from the actual collection.

Usual caveats apply

Download Source
Run Demo

Custom ILists, ComboBox Prompts

| 1 Comment

Following up on the last post which showed how to use custom ILists to merge two collections, this post shows how to use a custom IList to concatenate or append two collections.

Such a thing might be useful in a situation where you want to add more than one prompt to a ComboBox. In the example, I have the days of the week to choose from, but also want to add "Every Day", "Weekdays" and "Weekends" without modifying the original days of the week collection. Of course, if you concatenate the two collections, it offsets your selectedIndex.

Download Source
Run Demo


Custom ILists, CheckBoxDataGrid, Merged Arrays

| 16 Comments

Earlier I published how to do a CheckBoxDataGrid where the selection model uses CheckBoxes instead of mouse clicks. I should have mentioned that the example used the DataGrid's selection logic which meant that the dataprovider item's selected state was not stored in the dataProvider and thus you couldn't sort by whether an item was selected or not.

If you have a selected field in your data, then the code to handle checkbox selection is quite different. You basically shut down the DataGrid's selection code and update the collection instead. You can see that in the source code for this example.

This example goes one step further, however. It assumes that you want to store selection in the dataProvider, but the dataProvider items don't have a selected field and are "immutable". The example code shows how to use a custom IList to merge two arrays or ArrayCollections into one merged collection where the data objects contain fields from both arrays. By doing that you can "add" a selected field to each item.

Custom ILists are a powerful way to change data without having to process each data item. The example code merges the items on-demand instead of up-front thus saving startup time. It would be wasteful to process 1000 items if you only show 7 and the user doesn't scroll past 20.

Anyway, here's the code. Usual caveats apply.

Download Source
Run Demo

About this Archive

This page is an archive of recent entries in the General category.

Advanced Topics is the previous category.

Item Renderers is the next category.

Find recent content on the main index or look in the archives to find all content.