0

解决了

我正在开发一个 Flex/PHP 应用程序。

我有一个用于数据源的 ArrayCollection,但有 8 个数据网格(命名为 dg1 到 dg8)。我使用 8 个数据网格进行逻辑演示(大学 4 年,每年 2 个学期)。我有一列带有“X”(用于“删除此记录”),单击时会转到一个函数。

我想做的是将数据网格 ID(例如“dg1”)和数据提供者 {syllabus.freshFall} 传递给函数。我一直在努力寻找我是如何做到这一点的,但只找到了单个数据网格的示例(看起来很容易)并引用了这样的单个固定数据网格:

course_id=dg1.selectedItem.course_ID;
syllabus.freshFall.removeItemAt(dg1.selectedIndex);

我想做这样的事情:

course_id=**whateverDataGrid**.selectedItem.course_ID;
**whateverDataProvider**.removeItemAt(**whateverDataGrid**.selectedIndex);

现在我需要帮助将我的 c_id 变量传递给我的 HTTPService。

感谢你的帮助!

4

1 回答 1

0

部分答案:

Adob​​e LiveDocs for Flex 3的帮助下

<mx:LinkButton label="X" click="outerDocument.itemClickEvent('1',event)"/>


public function itemClickEvent(id:String, event:MouseEvent):void {
        var mydp:Object;
        switch(int(id))
        {
            case 1:
                mydp=syllubus.freshFall;
                break;
                               .
                               .
                            case 8:
                mydp=syllubus.seniorSpring;

            default:
                trace("Out of range");
                break;
        }
        id = "dg" + id;
        c_id=this[id].selectedItem.course_ID;
        mydp.removeItemAt(this[id].selectedIndex);  //superficial datagrid delete

我仍然想让数据提供者更像一个变量,只是为了完整。我尝试了几种不同的方法,案例陈述最接近我想要的,并且现在有效

想办法将我的 c_id 变量从我的函数传递给我的 HTTPService。并不像我希望的那样直截了当……

在 Object 类型中构建一个变量 将一个元素添加到您要传递的变量名称的对象中 为该变量添加一个值。通过

它看起来像这样:

function blah (var:int, ...rest):void {

code...

code...

c_id= *whatever*;
params["cid"] = c_id;
update.send(params);  (where "update" is the HttpService id)
}

.
.
.
.

<mx:HTTPService 
    id="update"     
    url="http://localhost/myFile.php" 
    method="POST"  
    etc...>
 <mx:request>
   <xmlstring>{XMLString}</xmlstring>   (this xml string is generated elsewhere)
   <cid>c_id</cid>
 </mx:request>
</mx:HTTPService>

希望这对其他人有帮助。把这一切拼凑起来有点痛苦。

于 2011-03-24T03:07:45.070 回答