0

Person {pID、pName、deptID}とDepartments {deptID、deptName}の2つのテーブルがあります。このようなSQLステートメントは、個人の名前と部門名を取得します。

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

上記は問題なく動作します。deptNamesが入力されたFlexDropDownListがあります。送信ボタンをクリックすると、選択した部門の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を取得します。データグリッドを更新してdeptNameを表示するには、フラッシュアプ​​リをリロードする必要があります。

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

上記のコメントから、personを追加すると、1つの属性が部門からの外部ID(deptID)であることを除いて、personオブジェクトの属性が実際にデータグリッドに追加されることがわかります。

4

2 に答える 2

0

What I suspect is: Your select statement above is run only when you initialize/run your application for the first time. Anything you add afterwords, fails to call that select statement that brings the department name back using join statement and hence you only see the id until next load/initialization of whole app.

于 2011-07-19T13:31:22.777 に答える
0

インターフェイスに追加されているときに結合から取得していないため、 deptName プロパティを設定する必要があると思います。それで、このような何かが私が思うトリックをするべきですか?

編集:コンボボックスの代わりに4.5ドロップダウン用

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);
    }
}
于 2011-07-19T16:34:12.870 に答える