PDA

View Full Version : [SOLVED] Trying to load grid (in window) from main app combobox



mjhaston
11 Jan 2011, 7:37 AM
I have a main application in a viewport layout. In the center region I have some tabs with grids that are disabled until a selection is made from a combobox (combo-ssn). This all works well.

Now I'm trying to do something similar with a window containing a grid, but with no luck. You'll see in red font where I try and pass parms the same way I do to the grids that are in my tabpanel.

The latest message is:

Ext.getCmp('combo-ssn').getValue() is undefined

I don't think I'm understanding how the combobox and the window/grid can communicate.

PS - The code below is in it's own .js file while the rest of the code (containing the combobox) is in another .js file.





var dependentStore = new Ext.data.JsonStore({
url: '/cgidev2p/jsonStr010.pgm',
storeId: 'store',
autoLoad: false,
waitMsg: 'Loading ...',
root: 'data',
baseParams: {
recordID: Ext.getCmp('combo-ssn').getValue(),
start: 0,
limit: 20,
dummy: 'dependent-store-load'
},
fields: [{
name: 'name'
}, {
name: 'ssn'
}, {
name: 'id'
}, {
name: 'gender'
}, {
name: 'relationship'
}, {
name: 'type'
}, {
name: 'start-date'
}, {
name: 'end-date'
}, {
name: 'birth-date'
}, {
name: 'age'
}, {
name: 'status'
}],
paramNames: {
recordID: "recordID"
},
listeners: {
beforeload: function(store, meta){
meta.params.recordID = Ext.getCmp('combo-ssn').getValue();
}
}
});

var grid = new Ext.grid.GridPanel({
id: 'grid',
store: dependentStore,
stripeRows: true,
tbar: {
xtype: 'toolbar',
items: [{
xtype: 'button',
text: 'Add Dependent',
iconCls: 'icon-user_add'
}, {
xtype: 'button',
text: 'Edit Dependent',
iconCls: 'icon-user_edit'
}, {
xtype: 'tbfill'
}, {
xtype: 'button',
text: 'Delete Dependent',
iconCls: 'icon-user_delete'
}]
},
columns: [{
xtype: 'gridcolumn',
header: 'name',
dataIndex: 'name',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'ssn',
dataIndex: 'ssn',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'id',
dataIndex: 'id',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'gender',
dataIndex: 'gender',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'relationship',
dataIndex: 'relationship',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'type',
dataIndex: 'type',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'start-date',
dataIndex: 'start-date',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'end-date',
dataIndex: 'end-date',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'birth-date',
dataIndex: 'birth-date',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'age',
dataIndex: 'age',
sortable: true,
width: 100
}, {
xtype: 'gridcolumn',
header: 'status',
dataIndex: 'status',
sortable: true,
width: 100
}],
listeners: {
scope: this,
activate: function(panel){
this.Ext.StoreMgr.get('dependentStore').load({
params: {
recordID: Ext.getCmp('combo-ssn').getValue(),
start: 0,
limit: 20,
dummy: 'dependent-store'
}
});
}
}
});

var dependentsWindow = new Ext.Window({
deferredRender: true,
title: 'Dependents',
width: 600,
height: 300,
layout: 'fit',
closeAction: 'hide',
items: grid
});

Condor
11 Jan 2011, 7:44 AM
Does the combobox already exist when you create dependentStore (you are using it in baseParams)?

Why are you even setting recordID in baseParams? You are also setting it in beforeload.

mjhaston
11 Jan 2011, 8:00 AM
The answer to all of your questions is ... I'm not really sure because I don't know what I'm doing!

I'll move the code further down in the process. Perhaps combobox doesn't exist yet? Those baseParams all over the place is from me throwing examples together until one of them worked.

How it "should" work is the button to open this window/grid is not enabled until a selection is made from the combobox. Then when it is enabled and clicked, I'd like to pass the value to the store.

mjhaston
11 Jan 2011, 10:05 AM
It still tells me combo-ssn is undefined. Maybe I'm approaching this wrong? Is there a way to deferredRender a window with grid like I do with my tab with grid?

mjhaston
13 Jan 2011, 8:41 AM
Solved because I'm stupid. I didn't have a storeid.



storeId: 'dependentStore',