tags:

views:

42

answers:

1

I have an AvancedDataGrid that is fed with data like this:

<stat associate="Henry Smith" date="07/08/09" amount="1"/>
<stat associate="John Doe" date="07/08/09" amount="1"/>
<stat associate="John Doe" date="07/09/09" amount="2"/>

I want it to be so that when you click on a date in the date column, the associate and amount column only show that date. How can I do that?

Here is my AvancedDataGrid :

<mx:AdvancedDataGrid 
    id="wideGrid" 
    width="100%" 
    height="100%" 
    styleName="dataGrid"
    dataProvider="{_statsXMLList}"
>
    <mx:columns>
        <mx:AdvancedDataGridColumn id="wideGridCol1"
                dataField="@associate"
                headerText="Name"
                width="110"/>
        <mx:AdvancedDataGridColumn id="wideGridCol2"
                dataField="@amount"
                headerText="Amount"
                width="50" />
        <mx:AdvancedDataGridColumn id="wideGridCol3"
                dataField="@date"
                headerText="Date"
                width="60" />
    </mx:columns>
</mx:AdvancedDataGrid>
A: 

You need to write a filter function:

filterFunction:Function
A function that the view will use to eliminate items that do not match the function's criteria. A filterFunction is expected to have the following signature:

f(item:Object):Boolean
where the return value is true if the specified item should remain in the view.

And apply that to your XMLListCollection. The function should filter based on a date value stored somewhere.

When the user clicks a row, you set that date value, then call a refresh on your XMLListCollection. Since you've bound the collection to your datagrid, the table should update.

Is this what you're trying to do, or something special with the grouping?

Glenn