我有两个表:Person {pID, pName, deptID} 和 Departments {deptID,deptName} 像这样的 SQL 语句让我得到一个人的名字和部门的名字:
SELECT pName, departments.deptName FROM people INNER JOIN people.deptID = departments.deptID;
以上工作正常。我有一个填充了部门名称的 Flex DropDownList。当我单击提交按钮时,我能够毫无问题地获取所选部门的 ID:
protected function button_clickHandler(event:MouseEvent):void
{
person.pName=pNameTextInput.text;
person.deptID=pDepartmentDropDownList.selectedItem.deptID; //ID of selected department obtained correctly.
if (person.pID == 0)
{
createPersonResult.token=personService.createPerson(person);
}
else
{
updatePersonResult.token=personService.updatePerson(person);
}
}
我有一个 createPersonresult 处理程序,它会在添加人员时尝试更新数据网格。数据网格使用新添加的人员进行更新,但在部门列中,我从下拉列表中获取了部门的 ID。我需要重新加载 Flash 应用程序以刷新数据网格以显示部门名称。
此 createPerson 结果处理程序中缺少某些内容。谷歌没有提供太多帮助。
protected function createPersonResult_resultHandler(event:ResultEvent):void
{
currentState="PeopleDetails";
person.pID=event.result as int;
peopleDg.dataProvider.addItem(person); //the problem might be here, more below.
peopleDg.setSelectedIndex(peopleDg.dataProvider.getItemIndex(person));
peopleDg.ensureCellIsVisible(peopleDg.selectedIndex);
}
从上面的评论中,我看到添加人员确实会将人员对象的属性添加到数据网格中,除了一个属性是来自部门的外部 ID (deptID)。