开发者

Select item in details form dropdown when datagrid item is selected

I have this datagrid:

<mx:DataGrid id="dgCompetenteN" includeIn="Test" left="10" right="472" top="69" b开发者_C百科ottom="149"
             dataProvider="{colCompetente}" editable="false">
    <mx:columns>
        <mx:DataGridColumn headerText="ID Competență" dataField="idCompetenta"/>
        <mx:DataGridColumn headerText="Denumire Competență" dataField="denCompetenta"/>
        <mx:DataGridColumn headerText="Competență Superioară" dataField="idCompSuperioara" rendererIsEditor="true" editorDataField="idCompSuperioara" itemRenderer="renderers.CompetentaSuperioara"/>
    </mx:columns>
</mx:DataGrid>

and this form:

<s:Form includeIn="Test" x="536" y="69">
    <s:FormItem label="Denumire competenta">
        <s:helpContent>
            <s:Label text="Help String"></s:Label>
        </s:helpContent>
        <s:TextInput text="{dgCompetenteN.selectedItem.denCompetenta}"/>
    </s:FormItem>
    <s:FormItem label="Competenta superioara">
        <s:helpContent>
            <s:Label text="Help String"></s:Label>
        </s:helpContent>
        <s:DropDownList dataProvider="{colCompetente}" 
                        labelField="denCompetenta">
        </s:DropDownList>
    </s:FormItem>
</s:Form>

What I want to do is, when I select an item in the datagrid, the selected item of the dropdown should be the correct one (the one which has the field idCompSuperioara equal to the third element in the selected datagrid row).

Any ideas?

Thank you.


Try something along these lines:

The itemClickHandler:

protected function dgCompetenteN_itemClickHandler(event:ListEvent):void
{
  for each (var o:Object in colCompetente)
  {
    if (o.idCompSuperioara == dgCompetenteN.selectedItem.idCompSuperioara)
    {
      ddlCompetenta.selectedItem = o;
      break;
    }
  }
}

The DataGrid:

<mx:DataGrid id="dgCompetenteN" includeIn="Test" left="10" right="472" top="69" bottom="149" dataProvider="{colCompetente}" editable="false" itemClick="dgCompetenteN_itemClickHandler(event)">
  <mx:columns>
        <mx:DataGridColumn headerText="ID Competență" dataField="idCompetenta"/>
        <mx:DataGridColumn headerText="Denumire Competență" dataField="denCompetenta"/>
        <mx:DataGridColumn headerText="Competență Superioară" dataField="idCompSuperioara" rendererIsEditor="true" editorDataField="idCompSuperioara" itemRenderer="renderers.CompetentaSuperioara"/>
    </mx:columns>
</mx:DataGrid>

The form:

<s:Form includeIn="Test" x="536" y="69">
    <s:FormItem label="Denumire competenta">
        <s:helpContent>
            <s:Label text="Help String"></s:Label>
        </s:helpContent>
        <s:TextInput text="{dgCompetenteN.selectedItem.denCompetenta}"/>
    </s:FormItem>
    <s:FormItem label="Competenta superioara">
        <s:helpContent>
            <s:Label text="Help String"></s:Label>
        </s:helpContent>
        <s:DropDownList id="ddlCompetenta" dataProvider="{colCompetente}" 
                        labelField="denCompetenta">
        </s:DropDownList>
    </s:FormItem>
</s:Form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜