【问题标题】:FLEX: Dynamically accessing multiple datagrids by passing caller object ids to a functionFLEX:通过将调用者对象 ID 传递给函数来动态访问多个数据网格
【发布时间】:2011-07-20 17:43:34
【问题描述】:

已解决

我正在开发一个 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。

感谢您的帮助!

【问题讨论】:

    标签: php apache-flex data-binding datagrid arraycollection


    【解决方案1】:

    部分答案:

    在Adobe 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>
    

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

    【讨论】:

      猜你喜欢
      • 2014-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-03
      • 2021-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多