I have a datagrid where users put in different numbers for 3 different columns. These values are then calculated after the user puts in each value for each column. I also have a combobox component inside my datagrid. What I want this combobox to do is perform a different mathematical formula based on what the user selects. For example, in the combobox if the user selects 'Long'(the first option in the combobox) it performs Column1*(col2-Col3)-col4=total column or if the user selects 'Short'(the second option in the combobox) it performs col1*(Col3-col2)+column4=total column. How would I do that? I've tried different ideas none which have seemed to work so any examples or suggestions would be greatly appreciated.
public function getTotal(item:Object, column:DataGridColumn):String
{
switch(comboBox)
{
case "Long":
var sum:int = item.quantity*(item.exit-item.entry)-item.commission;
return currencyFormatter.format(sum);
case "Short":
sum = item.quantity*(item.entry-item.exit)-item.commission;
return currencyFormatter.format(sum);
}
}