cancel
Showing results for 
Search instead for 
Did you mean: 

Can I dynamically add property to the model by changing the property of controls with data binding?

Former Member
0 Kudos

Hi all,

I try to bind model to the control —item. And the property 'selected' bind to model which is undefined by default. Whether the property will be added if I select this item? I try it and found it can't be created. So the way is to catch the select event and call setProperty of model to add it? Thanks for any suggestion.

Thanks,

Mengchi

Accepted Solutions (0)

Answers (1)

Answers (1)

saivellanki
Active Contributor
0 Kudos

Hi Mengchi,

You mean something like this?  Plunker

Checked is a property added in the model. And once you check the combobox placed in each item, you see the value gets changed to true / false.

Working Snippet:

Regards,

Sai.

Former Member
0 Kudos

Hi Sai,

I saw these code in the file.


var oProducts = oSource.getProperty("/ProductCollection");

            $(oProducts).each(function(i, e) {

              oProducts[i]['Checked'] = "";

            })

So I need to add the property in the model at first. The model can't be add property dynamically right?

Thanks,

Mengchi

saivellanki
Active Contributor
0 Kudos

Mengchi,

Yes, we have to create key value pair, if you're able to fetch from back-end then this code is not required.

If you don't want to create at model definition, then an alternative would be something like this: Plunker

Regards,

Sai.