0

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!

MBK
  • 307
  • 6
  • 23

1 Answers1

3

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);
Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66
  • Now I have associated data in JSON format. i was able to retrieve the associated data via 'var data_assoc= record.getData(true);' which gets me the associated data as well. Now, w.down('form').getForm().loadRecord(data_assoc); It says Object # has no method 'getData' i.e. beacause, loadRecord is a Basic form method which takes only record as paramaeter. So, now could u please suggest anything on this? Instead of doing it in (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.reader.Reader) way, I used getData(true) which did the magic.Thank you in advance. – MBK Sep 12 '13 at 20:55