0
votes

I have build an extJs 4.2 MVC pattern application. I have agrid in the front page. On dbclick of an item in the grid, a pop up window is appearing which is working fine. The pop up window extends a window and has forms in it. The form displays the details of the item clicked. If its a single field, in the controller i can specify it in the

`onGridItemDblClick : function(view, record, item, index, e) {

var view = Ext.widget('xtype_name_for_window');
field= view.down('displayfield');
field.setValue(record.get('name_of_the_field'));

}`

But (yes, there is but, or I wouldn't have posted this) I have many fields to be displayed in the window. How can I popullate all the fields?

Thank you!

1

1 Answers

3
votes

Use the functionality of forms:

Ext.define('MyRec', {
    extend: 'Ext.data.Model',
    fields: ['f1', 'f2', 'f3']
});

var w = new Ext.window.Window({
    width: 400,
    height: 200,
    title: 'Foo',
    autoShow: true,
    layout: 'fit',
    items: {
        xtype: 'form',
        defaultType: 'displayfield',
        items: [{
            name: 'f1'
        }, {
            name: 'f2'
        }, {
            name: 'f3'
        }]
    }
});

var rec = new MyRec({
    f1: 'a',
    f2: 'b',
    f3: 'c'
});

w.down('form').getForm().loadRecord(rec);