tags:

views:

2121

answers:

2

HI,

I have a datagrid with 6 columns, each with its own item renderer. In the first column i want to be able do a check and see if the column contains some valid data, if not then i want to skip this row and go to the next. In other words i want a way to tell my datagrid to stop processing the rest of the item renderers for the current data object and skip to the next. Any ideas?

+1  A: 

I'd say your best bet is to use the filterFunction property on ListCollectionView objects (such as ArrayCollection). This allows you to filter out the objects you don't want to show in your DataGrid before they're displayed in the grid, and should avoid any itemRenderers being processed altogether.

Dan
A: 

If you still want the "skipped" object to display in the data grid and just change how the item renderers respond to it, then you'll need to write code for that in the renderers.

Inside of the item renderer, you can access the data values of the previous columns. You should examine the listData property available in the item renderer and use your findings to configure how the item renderer should display.

You can find information about the listData here: http://livedocs.adobe.com/flex/3/langref/mx/controls/dataGridClasses/DataGridListData.html

To examine previous values, you might code something like this:

var dgListData:DataGridListData = DataGridListData( listData );

// Process all columns before the current one.
for ( var i:int = 0; i < dgListData.columnIndex; i++)
{
    // Do something here to examine previous data

    // If we should stop processing based on previous values
    // then hide everything inside of this renderer (perhaps
    // move to a state name 'empty' that has no children), else
    // move to the state that renders something.
    currentState = shouldSkipObject ? 'empty' : 'normal';
}

If you want more specific help writing the code inside of the item renderer, please include a sample of what the data looks like inside of the data grid as well as a description of what the item renderer should actually do.

darronschall