PDA

View Full Version : getForm in custom component



Chupa
26 Oct 2010, 4:10 AM
Hello.
I try to create grid-form binding like in example: http://dev.sencha.com/deploy/dev/examples/form/form-grid.html
But i use custom component that extends from FormPanel. When i call self.getForm() i don't get BasicForm object. self is my component.

Component code:


Ext.ns('TNS.modules');

TNS.modules.ResourcesModule = Ext.extend(Ext.FormPanel, {
id: 'logical-resources-facade',

initComponent: function() {
var self = this;

Ext.applyIf(this, {
layout: 'hbox',
bodyStyle: "background:none",
layoutConfig: {
align : 'stretch',
pack : 'start'
},
items: [
{
flex: 1,
bodyStyle: "background:none",
layout: 'fit',
items: {
xtype: 'LogicalResourceGrid'
}
},
{
width: 500,
xtype: 'fieldset',
labelWidth: 90,
title: 'Edit resource',
defaults: {width: 300, border:false},
defaultType: 'textfield',
autoHeight: true,
border: false,
items: [
{
fieldLabel: 'Name',
name: 'name'
},
{
fieldLabel: 'Commercial region ID',
name: 'commercialRegionId'
},
{
fieldLabel: 'Is default?',
name: 'isDefault'
},
{
fieldLabel: 'Specification',
name: 'resourceSpec'
}
]
}
]
});

TNS.modules.ResourcesModule.superclass.initComponent.call(this);

this.specGrid = this.items.itemAt(0).items.itemAt(0);

this.specGrid.on({
scope: this,
viewready: function(g) {
g.getSelectionModel().on({
rowselect: function(sm, row, rec) {
self.getForm().loadData(rec);
}
});
g.getSelectionModel().selectRow(0);
}
})
}
});

Ext.reg('ResourcesModule', TNS.modules.ResourcesModule);


What i'm doing wrong? I want to populate form fields from selected row.