0

I have ViewModel, and one of its fields contains array of objects. How can I create items: [] dynamically based on data of that field? Actually I need something like grid, but a bit more complex and with different layout. I guess I have to listen something like 'onChange' event for ViewModel, and do :

this.add(Ext.create('MyItem', {data: ElementOfArrayFromVMField}))

Is this right way?

Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26
Arkady
  • 1,178
  • 14
  • 35

1 Answers1

0

Finally, I found the way, which CD pointed, is the best. I extended Panel as Periods, and created method setPeriods. Then binding works perfectly. Most important thing - is the prefix 'set' in the metod, that named like bound field.

...
xtype: 'Periods',
bind: {
    periods: '{veiwmodel.periods}'
}
...

and inside Periods:

Ext.define('Myapp.view.Periods', {
extend: 'Ext.panel.Panel',
...
setPeriods: function(items) {
    this.removeAll(true);
    this.add({...});
}
Arkady
  • 1,178
  • 14
  • 35