PDA

View Full Version : Grid not in form



randomuser01
12 Sep 2008, 10:57 AM
I have the following nested layout. When I attempt to get to the grid through this.form, I get back undefined. However, I can get to all other fields just fine.

Could you pls point out what I'm doing wrong?
Thanks




MyApp.MyPopup = Ext.extend(Ext.FormPanel, {
...
Ext.apply(this, {
layout:'border' ,frame:false ,
items:[{
region:'center',title: 'Information',layout:'fit'
,items:[{
xtype:'panel',layout:'form',frame:true ,labelWidth:70,
items:[{
// some textboxes and combos
}]
}]
},{
title:'Companies',region:'east',layout:'accordion',width:250
,items:[{
xtype:'panel',layout:'fit',
,items:[{
// combo
}]
},{
xtype:'panel',title:'All',layout: 'fit',
items:[{
xtype: 'grid',ds:allDS,id:'AllCtl',name:'AllCtl',
cm: new Ext.grid.ColumnModel([
sm2,
{id:'item',header: 'Name',sortable: true,locked:false,dataIndex: 'item'}
]),
sm:sm2,viewConfig: {forcefit:true},frame:true
}]
}]
}]
,buttons: [{
text: 'Save' , scope:this,
handler:function() {
var ctl = this.form.findField('AllCtl');
// ctl is null but all other fields I can get to

return;

carol.ext
12 Sep 2008, 11:03 AM
A grid is not a field in a form. It is a component, though. (You should have shown this code in your other post.)

Instead of


var ctl = this.form.findField('AllCtl');

Try


var ctl = Ext.getCmp('AllCtl');

randomuser01
12 Sep 2008, 11:05 AM
Thank you.. I thought I'd tried it earlier but I was wrong.

mjlecomte
12 Sep 2008, 4:24 PM
For the OP: In case you're not aware there's a FAQ that has solutions to some situations like this. Check it out sometime. http://extjs.com/learn/Ext_FAQ_Grid#Grid_within_form