FLEX:通过将调用者对象 ID 传递给函数来动态访问多个数据网格

发布于 2024-10-24 15:36:22 字数 677 浏览 4 评论 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。

感谢您的帮助!

SOLVED

I have a Flex/PHP app I'm working on.

I have a single ArrayCollection for a data source, but have 8 datagrids (named dg1 through dg8). I use 8 datagrids for logical presentation (4 years of college, 2 semesters per year). I have a column with "X" (for "delete this record") that goes to a function when clicked.

What I'd like to do is pass the datagrid id (such as "dg1") and the data provider {syllabus.freshFall} to a function. I've been trying my hardest to find how I do this, but have only found examples of single datagrids (which look pretty easy) and referring to a single fixed datagrid like this:

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

I want to make this something like this:

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

NOW I need help passing my c_id variable to my HTTPService.

Thanks for ALL your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So要识趣 2024-10-31 15:36:22

部分答案:

的帮助下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。并不完全像我希望的那么直接......

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

它看起来像这样:

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>

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

PARTIAL ANSWER:

with help from 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

I would still like to make the data provider more of a variable, just to be complete. I tried several different approaches and the case statements were the closest to what I wanted and it worked for now.

Figured out passing my c_id variable from my function to my HTTPService. Not exactly as straight-forward as I would have hoped...

Build a variable in the type of Object
Add an element to the object of the name of your variable you want to pass
Add a value for the variable.
Pass the

It looks like this:

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>

Hope this helps someone else. It's been a bit of a pain to piece this all together.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文