Forum Discussion

kcsahu777's avatar
kcsahu777
Contributor
13 years ago

How to refer object property by using a variable?

How to refer object name that is stored in a variable?



Suppose the property "clearer" is referred as below

TradeDataGrid.FlexObject.dataProvider.list.source.item(row).clearer



But if the name is stored in a variable say  v_clr="clearer"



I want to refer it something like below, which is not working now



TradeDataGrid.FlexObject.dataProvider.list.source.item(row).v_clr



Error throwing as below



 Object doesn't support property or method:v_clr



Had this been worked, I could reduce several lines of code .


3 Replies

  • windend's avatar
    windend
    Occasional Contributor
    Try using "Eval" on the results to return the actual object. In your case, it should be



    Set Obj = Eval("TradeDataGrid.FlexObject.dataProvider.list.source.item(row)."&v_clr)



    The object you want will be returned.



    I'm also wonderring if there are some other ways.
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Krushna and Amy,


    I'm also wonderring if there are some other ways.


    As far as I know, you can also use the following approach:



    aqObject.GetPropertyValue(TradeDataGrid.FlexObject.dataProvider.list.source.item(row), v_clr)



     If you use JScript, you can also use the bracket notation:



    TradeDataGrid.FlexObject.dataProvider.list.source.item(row)[v_clr]


    I hope this information helps :)

  • Thanks a lot Amy and Irina.


    This helped me to reduce the lines of code.