任何身体可以帮我解决flex中的绑定问题吗?

时间:2015-03-12 19:45:15

标签: actionscript-3 flex

我写了以下内容:

<mx:DataGrid id="courseslist" includeIn="Classes,Dorat,LogIn,Main,Students,Teachers"
                             x="11" y="160" width="1142" height="240"
                             creationComplete="courseslist_creationCompleteHandler(event)"
                             editable="true" itemClick="courseslist_itemClickHandler(event)"
                             showHeaders="false" textAlign="right">                         
                    <mx:columns>
                        <mx:DataGridColumn dataField="category" width="90" editable="true"  editorDataField="selectedItem" activate="datagridcolumn1_activateHandler(event)" itemEditor="{inlineEditor}">
                        </mx:DataGridColumn>
                        <mx:DataGridColumn id="combostaff" dataField="teacher" width="170" editable="true" editorDataField="selectedItem">
                            <mx:itemEditor>
                                <fx:Component>
                                    <mx:ComboBox dataProvider="{parentDocument.staffnames}">
                                    </mx:ComboBox>
                                </fx:Component>   
                            </mx:itemEditor>

                        </mx:DataGridColumn>
                        <mx:DataGridColumn dataField="maxno" width="79"/>
                        <mx:DataGridColumn dataField="regno"/>
                        <mx:DataGridColumn dataField="minno"/>
                        <mx:DataGridColumn  dataField="startdate" width="120"
                                            itemRenderer="mx.controls.DateField"
                                            rendererIsEditor="true"
                                            editorDataField="selectedDate" />
                        <mx:DataGridColumn dataField="coursecreation" editable="false"/>
                        <mx:DataGridColumn  dataField="enddate" width="120"
                                            itemRenderer="mx.controls.DateField"
                                            rendererIsEditor="true"
                                            editorDataField="selectedDate"/>
                        <mx:DataGridColumn dataField="cost" />

                        <mx:DataGridColumn dataField="coursename"  />
                    </mx:columns>
                </mx:DataGrid>

和员工姓名是:

 public var staffnames:Array = new Array();

从服务中获取其价值:

public function getAllStaff_resultHandler(event:ResultEvent):void
            {
                tutortable.dataProvider=getAllStaff.lastResult;
                staffnames = new Array();
                for each (var i:Staff in getAllStaff.lastResult) 
                {
                    staffnames.push(i.name);
                    staff.push(i);

                }   

            }

但是我没有填充组合框也有人员名称填充数据,而是我得到这个错误: 警告:无法绑定到类'spark.skins.wireframe :: ApplicationSkin'上的属性'staffnames'

1 个答案:

答案 0 :(得分:0)

outerDocument.staffnames中使用dataprovider,如下所示。

使数组可绑定,如:

[Bindable]
public var staffnames:Array;

提供dataProvider,如:

<fx:Component>
   <mx:ComboBox dataProvider="{outerDocument.staffnames}">
         </mx:ComboBox>
</fx:Component> 

服务价值:

public function getAllStaff_resultHandler(event:ResultEvent):void
            {
                tutortable.dataProvider=getAllStaff.lastResult;
                staffnames = new Array();
                for each (var i:Staff in getAllStaff.lastResult) 
                {
                    staffnames.push(i.name);
                    staff.push(i);

                }   
             }

希望它有效。