PDA

View Full Version : Combo on Tbar - b is undefined



John Sourcer
14 Jun 2010, 12:49 AM
Hi All,

I create a combo as follows:




var combo_max_entries = new Ext.form.ComboBox({
triggerAction: 'all',
mode: 'local',
fieldLabel: 'Records',
id: 'max_entries',
editable: false,
width: 50,
store: new Ext.data.ArrayStore({
id: 0,
fields: ['entry', 'entry_display'],
data: [['10', '10'], ['20', '20'], ['50', '50'], ['100', '100'], ['200', '200']]
}),
listeners: {
render: function (c) {
this.setValue('10');
}
},
valueField: 'entry',
displayField: 'entry_display'
});



and add it to a grids tbar:




var grid = new Ext.grid.EditorGridPanel({
id: 'grid_claims',
/....
tbar: [combo_max_entries]
});



When I click on it the first time I get 'b is undefined'. The 2nd time I get 'this.list is undefined', it works fine in a form though.

What could cause this?

Condor
14 Jun 2010, 12:55 AM
Can't see anything wrong with this code.

Please try again with ext-all-debug.js and report the full error and line number.

John Sourcer
14 Jun 2010, 1:05 AM
Thanks Condor,

The problem is on line 38858: ct is undefined



if (this.ownerCt){
38857 this.findParentBy(function(ct){
38858 zindex = parseInt(ct.getPositionEl().getStyle('z-index'), 10);
38859 return !!zindex;
38860 });
38861 }


BTW, I can't seem to find the Ext IRC Channel.

Condor
14 Jun 2010, 1:22 AM
I don't understand how that method could fail...

Maybe it has something to do with setting the value on the render event. Why not simply specify value:'10' in the config options?

ps. Why are you even using a valueField in the combobox if the value and the display text are the same?

John Sourcer
14 Jun 2010, 1:28 AM
I've reduced it to:


var combo_max_entries = new Ext.form.ComboBox({
triggerAction: 'all',
mode: 'local',
fieldLabel: 'Records',
id: 'max_entries',
editable: false,
width: 50,
store: new Ext.data.ArrayStore({
id: 0,
fields: ['entry', 'entry_display'],
data: [['10', '10'], ['20', '20'], ['50', '50'], ['100', '100'], ['200', '200']]
}),
value: '10',
displayField: 'entry_display'
});

And still have the same problem. The grid works fine. I see the combo with initial value set to '10', but when I click on it the error is thrown.

Condor
14 Jun 2010, 1:47 AM
It looks like you are breaking the container structure somewhere (not in this code).

This works as expected:

new Ext.Viewport({
layout: 'fit',
items: {
xtype: 'editorgrid',
store: [[1, 'One'], [2, 'Two'], [3, 'Three']],
columns: [
{header: 'Number', dataIndex: 'field1', editor: new Ext.form.NumberField({allowBlank: false})},
{header: 'Text', dataIndex: 'field2', editor: new Ext.form.TextField({allowBlank: false})}
],
tbar: [{
xtype: 'combo',
store: ['10', '20', '50', '100', '200'],
editable: false,
triggerAction: 'all',
value: '10'
}]
}
});

John Sourcer
14 Jun 2010, 1:57 AM
Here is the full function where 'center' is a center region in a viewport set to layout border.




function createClaimPanel() {

var center = Ext.getCmp('center');

var ds = new Ext.data.JsonStore({
url: 'DataHandler.ashx',
root: 'claims',
fields: [{
name: 'claimId',
type: 'int'
}, {
name: 'claimNo',
type: 'string'
}],
baseParams: { i: 1, query: ''}
});

var cm = new Ext.grid.ColumnModel({
columns: [{
header: 'Claim ID',
width: 50,
sortType: 'asInt',
dataIndex: 'claimId'
}, {
header: 'Claim No',
width: 140,
sortType: 'asUCString',
dataIndex: 'claimNo'
}],
defaultSortable: true
});

var grid = new Ext.grid.EditorGridPanel({
id: 'grid_claims',
store: ds,
cm: cm,
title: 'Claims',
viewConfig: {
emptyText: 'No claims for selected period'
},
enableHdMenu: true,
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
loadMask: true,
listeners: {
render: function () {
this.loadMask.show();
var store = this.getStore();
store.load.defer(100, store, [{
params: {
i: '1'
}
}]);
},
delay: 400
},
tbar: [
{
xtype: 'combo',
store: ['10', '20', '50', '100', '200'],
editable: false,
triggerAction: 'all',
value: '10'
}
]
});

center.removeAll();
center.add(grid);
center.doLayout();
}

Condor
14 Jun 2010, 2:02 AM
Can't get it to fail on Ext 3.2.2. Which Ext version are you using?

John Sourcer
14 Jun 2010, 2:36 AM
3.2.1

John Sourcer
15 Jun 2010, 12:27 AM
Condor,

This is deffo a problem. It's happening in other sites I upgrade to 3.2.1 I'm setting up a test case to demo.