Reputation: 13
I have a datagrid. In this datagrid I have a combobox item editor. This datagrid also has multiple columns where a user inputs numbers in each column. These numbers are then calculated by formula where the sum is posted in the "total" column. In this combobox there are two options for the user to choose from and each option has a different formula for calculating the inputted numbers. What I want is for when a user chooses "option 1" one formula is used to do the calculation, when "option 2" is chosen by the user then formula two is used to the calculation.
Here's an example:
Combobox Option 1 (formula 1) is chosen by user = (Column2 - Column1) x column3 = "total" column
Combobox Option 2 (formula 2) is chosen by user = (Column1 - Column2) x column3 ="total" column
I realize you would use a conditional such as "if else" statement, but im just not sure how to do it. I've been trying to implement this for a while with no success so any help or suggestions would be greatly appreciated.
Upvotes: 1
Views: 733
Reputation: 74
Listen for the combobox's change
event and implement the formula calculation in the change
event handler according to the selectedItem
.
public function changeEventHandler(event:Event){
if(ComboBox(evt.target).selectedItem.label == forumla1) {
//logic
} else if(ComboBox(evt.target).selectedItem.label == formula2) {
//logic
} else {
//do nothing
}
}
Upvotes: 1
Reputation: 9897
That's interesting. You cannot add listeners directly because item renderers are reused and don't keep their identity. Some thoughts on problem:
Upvotes: 0