I want to connect these 3 together. When you choose from the togglebutton bar it will be displayed in the combobox, and from there you can choose other data that will be displayed in the datagrid.
Now I have the first two connected:
private function toggle(event:ItemClickEvent):void{
list2.selectedIndex=-1; // reset so prompt shows
if (togglebtn.selectedIndex==0)
list2.dataProvider=elecItems;
else if(togglebtn.selectedIndex==1)
list2.dataProvider=toyItems;
}
<mx:ToggleButtonBar id="togglebtn" x="9" y="29" color="0x323232" dataProvider="{dp}" horizontalGap="4" itemClick="toggle(event)"/>
<s:ComboBox id="list2" x="159" y="28" width="549" itemClick="select_item(event)"/>
now I want to connect the combobox with the datagrid, but when I use:
if (list2.selectedIndex==0)
info_dg.dataProvider={info};
it directs to two indexes…. anyway I don7t quite understand it myself and hope to get some help.
also instead of using SelectedIndex==0 could I use an ID instead?
Data structure:
ToggleButtonBar
[Bindable]public var dp:ArrayCollection = new ArrayCollection([
{label:"商品", data:399},
{label:"顧客", data:599}]);
Combobox
[Bindable]public var elecItems:ArrayCollection = new ArrayCollection([
{label:"text", data:299},
{label:"tttナビ", data:999},
{label:"大学院ttt", data:999},
{label:"ttt", data:999},
{label:"ttt制作", data:899},
{label:"tttt", data:899}]);
[Bindable]public var toyItems:ArrayCollection = new ArrayCollection([
{label:"text", data:120},
{label:"text", data:50},
{label:"text", data:50},
{label:"(株)text", data:30} ]);
Datagrid XML file:
<fx:XMLList id="Info">
<employee>
<name>eeee/完了</name>
<phone>eee</phone>
<email>eee制作</email>
<active>300,000</active>
<image>eeee</image>
</employee>
<employee>
<name>rrr/完了</name>
<phone>rrr</phone>
<email>rrr設営</email>
<active>1,900,000</active>
<image>rrrしないように</image>
</employee>
</fx:XMLList>
I have such a structure to save informations about employees
There are two toggle blocks to tell “toy” and “elec” apart.
Each block has a number of “group” items – each for the corresponding item in the CheckBox.
If it is ok, then you should not use any “if else”. Instead of it your function would look like
The “togglebtn.selectedIndex” selects a toggle block and the “list2.selectedIndex” selects a group of the toggle.