Flex 数据网格未正确更新 [英] Flex datagrid not updated properly

查看:25
本文介绍了Flex 数据网格未正确更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表:Person {pID, pName, deptID} 和 Departments {deptID,deptName}像这样的 SQL 语句让我得到一个人的名字和部门名称:

I have two tables: Person {pID, pName, deptID} and Departments {deptID,deptName} An SQL statement like this gets me the name of a person and the department name:

SELECT pName, departments.deptName FROM people INNER JOIN people.deptID = departments.deptID;

以上工作正常.我有一个填充了 deptNames 的 Flex DropDownList.当我点击提交按钮时,我可以毫无问题地获取所选部门的 ID:

The above works fine. I have a Flex DropDownList that is populated with deptNames. When I click the submit button, I am able to obtain the ID of the selected department without problem:

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 应用程序以刷新数据网格以显示部门名称.

I have a createPersonresult Handler that attempts to update the datagrid when a person is added. The datagrid is updated with the new added person, but in the department column, I get the ID of the department chosen from the dropdownlist. I need to reload the flash app to get the datagrid refreshed to display the deptName.

此 createPerson 结果处理程序中缺少某些内容.Google 没有提供太多帮助.

Something is missing in this createPerson result Handler. Google didn't provide much help.

   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).

From the comment above, I see that adding person will indeed add the attributes of the person object to the datagrid, except that one attribute is a foreign ID (deptID) from departments.

推荐答案

我认为你需要设置你的 deptName 属性,因为当它被添加到界面中时你没有从联接中获得它.所以我认为这样的事情应该可以解决问题吗?

I think you need to set your deptName property since you aren't getting it from the join when it's being added in the interface. So something like this should do the trick I think?

用于 4.5 下拉列表而不是组合框

for 4.5 dropdown instead of combobox

protected function button_clickHandler(event:MouseEvent):void
{
    person.pName=pNameTextInput.text;
    person.deptID=pDepartmentDropDownList.selectedItem.deptID; //ID of selected department obtained correctly.
    person.deptName = pDepartmentDropDownList.selectedItem.deptName;
    if (person.pID == 0)
    {
        createPersonResult.token=personService.createPerson(person);
    }
    else
    {
        updatePersonResult.token=personService.updatePerson(person);
    }
}

这篇关于Flex 数据网格未正确更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆