-1

I want to send value from one view to another one, I have a code that's work in ExtJS 6 but not in ExtJS 4.

This is from the first one:

var test = Ext.create('test.text', {
    delayedRenderTo: container_id,
    id: 'messageBox-' + meta.rowIndex,
    viewModel: {
        data: {
            value: value
        }
    }
});

and we bind it like this:

Ext.define('test.text', {
    extend: 'Ext.Panel',
    layout: {
        type: 'vbox',
        align: 'stretch',
        overflow: 'scroller',
    },
    items: [{
        xtype: 'textareafield',
        grow: true,
        growMin: 30,
        growMax: 120,
        disabled: true,
        fullscreen: true,
        bind: {
            value: '{value}',
        },
        fieldStyle: 'font-weight:bold;'
    }]
});

What is the alternative for ExtJS 4 ?

Rohit Sharma
  • 1,402
  • 9
  • 20
lomed
  • 51
  • 7

1 Answers1

1

ViewModels were introduced in Ext JS 5 which is why it doesn't work in Ext JS 4.

To do it in Ext JS 4, you'd have to find the component (the textareafield in this case) and then execute the setter (setValue for this example). It's all manual in Ext JS 4.

Getting the component depends on many things but the best way is to use ComponentQuery and depends where the code executing this would be. First, you'd have to get your test.text instance and then use comp.child('textareafield'). I cannot give you a silver bullet example as it depends on many factors but using component's down, child, query, up methods a good start and they all have different purposes.

Mitchell Simoens
  • 2,516
  • 2
  • 20
  • 29