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

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

问题描述

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

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

上述工作正常。我有一个Flex DropDownList填充了deptNames。当我点击提交按钮,我能够获得所选部门的ID没有问题:

$ p $ 受保护的功能button_clickHandler(event :MouseEvent):void
{
person.pName = pNameTextInput.text;
person.deptID = pDepartmentDropDownList.selectedItem.deptID; //所选部门的ID正确获得
if(person.pID == 0)
{
createPersonResult.token = personService.createPerson(person);
}
else
{
updatePersonResult.token = personService.updatePerson(person);




$ b我有一个createPersonresult处理程序试图更新数据网格当一个人被添加。数据网格用新添加的人员进行更新,但是在部门列中,我从下拉列表中获得所选部门的ID。我需要重新加载Flash应用程序,以刷新数据网格显示deptName。



在这个createPerson结果处理程序中缺少的东西。 Google没有提供太多的帮助。
$ b $ pre $ protected function createPersonResult_resultHandler(event:ResultEvent):void
{
currentState =PeopleDetails;
person.pID = event.result as int;
peopleDg.dataProvider.addItem(person); //问题可能在这里,下面更多。
peopleDg.setSelectedIndex(peopleDg.dataProvider.getItemIndex(person));
peopleDg.ensureCellIsVisible(peopleDg.selectedIndex);





$ b从上面的注释中我看到添加人确实会添加属性该人对象到数据网格,除了一个属性是来自部门的外部ID(deptID)。

解决方案

我想你需要设置你的deptName属性,因为你没有从连接中获取它,接口。所以这样的事情应该做的伎俩,我想?



编辑:为4.5下拉式,而不是combobox

  protected function button_clickHandler(event:MouseEvent):void 
{
person.pName = pNameTextInput.text;
person.deptID = pDepartmentDropDownList.selectedItem.deptID; //所选部门的ID正确获得
person.deptName = pDepartmentDropDownList.selectedItem.deptName;
if(person.pID == 0)
{
createPersonResult.token = personService.createPerson(person);
}
else
{
updatePersonResult.token = personService.updatePerson(person);
}
}


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;

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);
    }
  }

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.

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);
   }

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.

解决方案

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?

EDIT: 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天全站免登陆