views:

33

answers:

3

Hi,

I have Flex 4 DataGrid, what I would like to do is when an cell has been edited, I would then like to walk through the values of that column and preform math on the values, eg I want to total up certain values.

1) How do I reference individual values of a specific column so that I may set them. 2) How do I then set those values or should I create a new column array and pop it in place of that column.

Please and thank you in Advance. Craig

A: 

Hey Craig,

A way to do it in Flex 3 would be to add an event listener on the grid for the ItemEditEnd event. In the handler of that event, you would iterate over your the dataprovider and perform and calculations and updates needed.

When you update the items in your dataprovider, the updated values will be reflected in your grid.

I imagine you would do something similar in Flex 4.

--ron

I eventually cast the dataprovider into a list view and used getitem to mess with values.
Craig Mc
A: 

You can also listen to CollectionChangeEvent of your dataProvider, check its type, and if this is a PropertyChangeEvent that triggered it - check the name of the property that was changed, and depending on the property perform the calculations. This will work if you change the value not only from dataGrid. And, you would want the calculated values to be marked [Bindable] to have the changes reflected in the UI.

A: 

var data_field:String = dgViewPreview.columns[6].dataField; //for 6th column ListCollectionView(dataGrid.dataProvider).getItemAt(requiredRow)[data_field] = newValue;

Thanks to Armagosh for the idea.

Craig Mc