简体   繁体   中英

How to pass dynamic values as field name for an array collection in flex 3

 public function Adddynamic_values(val:String):void
        {
            for(var i:int=0;i<Gridvaltest.length;i++)
            {
                Gridvaltest.setItemAt({label:"A",number:"1",val:val},i);
            }

        }

This is my code. Now i want to know how to add dynamic value as field name for an array collection. Is it possible or any other way to do like this?

If we are passing the "val" value like mentioned above example

it cosidered as string ie ( I have attached little bit of code for better understand)

    [1] (Object)#4
    label = "A"
    number = "1"
    val = "233.5"

I got this was the output. But i want like this ( if the dynamic value will be "val" = 255 )

   [1] (Object)#4
    label = "A"
    number = "1"
    255 = "233.5"

Change your parameter val into something other than val like ""value".

public function Adddynamic_values(value:String):void
{
    for(var i:int=0;i<Gridvaltest.length;i++)
    {
        Gridvaltest.setItemAt({label:"A",number:"1",val:value},i);
    }
}

This should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM