Hi I have the following ArrayCollection:
priceModel.model.arrayProducts.addItem( {'productID':pc.productID, 'product':pc.product,
'provider1': {'value':0, 'selected':false}, 'provider2': {'value':0, 'selected':false}, 'provider3': {'value':0, 'selected':false}, 'provider4': {'value':0, 'selected':false}, 'provider5': {'value':0, 'selected':false}, 'provider6': {'value':0, 'selected':false});
I have a set Products and the question is that I need to iterate over the Products and access to a certain provider like for example:
priceModel.model.arrayProducts[product_index].('provider'+(idx+1)).value;
This does not work. How can i focus the code to getting access in each product to it's provider_X?
Thanks.
for ArrayCollection you cant use [] syntax - you have to use getItemAt to access the item:
priceModel.model.arrayProducts.getItemAt(product_index)
To access a property of the object 'dynamically' you conversely do use []:
['provider'+(idx+1)].value;
So this should work:
priceModel.model.arrayProducts.getItemAt(product_index)['provider'+(idx+1)].value;