PDA

View Full Version : Very strange combobox and firebug issue



fruitwerks
12 Aug 2009, 5:58 PM
I have been poking about on this project for a while, adding this and that when I have some time. Im not sure when it happened, but now the grid will not render unless firebug is open! (confirmed on three machines, W7, XP and Linux, FF3.x, IE7/8)

It does not work in IE at all... another thing is that when it does work, my species column only renders sometimes, the money and caps renderers also fail everytime.


Ext.onReady(function() {

var speciesDB = new Ext.data.Store({
reader: new Ext.data.JsonReader({
id: 'species_idx',
fields: ['species_idx', 'species'],
root: 'rows'
}),
proxy: new Ext.data.HttpProxy({
url: 'species.php'
}),
autoLoad: true
});
Ext.util.Format.comboRenderer = function(species_edit) {
// console.log('combo action');
return function(value) {
var record = species_edit.findRecord(species_edit.valueField, value);
return record ? record.get(species_edit.displayField) : species_edit.valueNotFoundText;
};
};

var animalsDB = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'quickchart.php',
method: 'POST'
}),
reader: new Ext.data.JsonReader({
id: 'idx',
root: 'results'
// totalProperty: 'total'
}, [{
name: 'idx',
type: 'int'
}, {
name: 'animal_id',
type: 'int'
}, {
name: 'bday',
type: 'date',
dateFormat: 'Y-m-d'
}, {
name: 'pdate',
type: 'date',
dateFormat: 'Y-m-d'
}, {
name: 'sdate',
type: 'date',
dateFormat: 'Y-m-d'
}, {
name: 'pprice',
type: 'int',
renderer: Ext.util.usMoney
}, {
name: 'sprice',
type: 'int',
renderer: 'usMoney'
}, {
name: 'mom',
type: 'int'
}, {
name: 'dad',
type: 'int'
}, {
name: 'bin',
type: 'string',
renderer: Ext.util.Format.capitalize
}, {
name: 'genetic',
type: 'string',
renderer: Ext.util.Format.capitalize
}, {
name: 'aname',
type: 'string'
}, {
name: 'foil',
type: 'string'
}, {
name: 'feedfreq',
type: 'int'
}, {
name: 'sid',
type: 'string'
}, {
name: 'sex',
type: 'string'
}, {
name: 'status',
type: 'auto'
}]),
sortInfo: {
field: 'animal_id',
direction: "ASC"
}
});

animalsDB.load({
params: {
start: 0,
limit: 30
}
});

var id_edit = new Ext.form.TextField();
bday_edit = new Ext.form.DateField({
format: 'm/d/Y'
});
pday_edit = new Ext.form.DateField({
format: 'm/d/Y'
});
sday_edit = new Ext.form.DateField({
format: 'm/d/Y'
});
var pprice_edit = new Ext.form.TextField();
var sprice_edit = new Ext.form.TextField();
var mom_edit = new Ext.form.TextField();
var dad_edit = new Ext.form.TextField();
var bin_edit = new Ext.form.TextField();
var genetic_edit = new Ext.form.TextField();
var aname_edit = new Ext.form.TextField();
var foil_edit = new Ext.form.TextField();
var ff_edit = new Ext.form.TextField();
var species_edit = new Ext.form.ComboBox({
store: speciesDB,
displayField: 'species',
valueField: 'species_idx',
allowBlank: false,
forceSelection: true,
triggerAction: 'all'

});
var sex_edit = new Ext.form.TextField();
var status_edit = new Ext.form.TextField();

var grid = new Ext.grid.EditorGridPanel({
renderTo: Ext.getBody(),
id: 'fsgrid',
frame: false,
title: 'Animals QuickChart',
height: 660,
width: 900,
store: animalsDB,
columns: [{
header: 'ID',
dataIndex: 'idx',
readOnly: true,
hidden: true
}, {
header: 'aid',
dataIndex: 'animal_id',
hidden: true,
sortable: true,
editor: id_edit
}, {
header: 'aname',
dataIndex: 'aname',
sortable: true,
editor: aname_edit
}, {
header: 'staus',
dataIndex: 'status',
hidden: true,
sortable: true,
editor: status_edit
}, {
header: 'gender',
dataIndex: 'sex',
hidden: true,
sortable: true,
editor: sex_edit
}, {
header: 'genetic',
dataIndex: 'genetic',
sortable: true,
editor: genetic_edit
}, {
header: 'birthday',
dataIndex: 'bday',
sortable: true,
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
editor: bday_edit
}, {
header: 'species',
dataIndex: 'sid',
sortable: true,
editor: species_edit,
renderer: Ext.util.Format.comboRenderer(species_edit)
}, {
header: 'feedfreeq',
dataIndex: 'feedfreq',
sortable: true,
editor: ff_edit
}, {
header: 'purchased',
dataIndex: 'pdate',
sortable: true,
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
editor: pday_edit
}, {
header: 'sold',
dataIndex: 'sdate',
hidden: true,
sortable: true,
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
editor: sday_edit
}, {
header: 'paid',
dataIndex: 'pprice',
sortable: true,
editor: pprice_edit
}, {
header: 'sale',
dataIndex: 'sprice',
hidden: true,
sortable: true,
editor: sprice_edit
}, {
header: 'mom',
dataIndex: 'mom',
hidden: true,
sortable: true,
editor: mom_edit
}, {
header: 'dad',
dataIndex: 'dad',
hidden: true,
sortable: true,
editor: dad_edit
}, {
header: 'foil',
dataIndex: 'foil',
hidden: true,
sortable: true,
editor: foil_edit
}, {
header: 'bin',
dataIndex: 'bin',
sortable: true,
editor: bin_edit
}],
listeners: {
afteredit: function(e) {
var conn = new Ext.data.Connection();
conn.request({
url: 'quickchart.php?act=update',
params: {
id: e.record.id,
field: e.field,
value: e.value
},
success: function(resp, opt) {
grid.getStore().getById(opt.params.id).commit();
},
failure: function(resp, opt) {
grid.getStore().getById(opt.params.id).reject();
}
});
// console.log('After edit fired');
}
},
tbar: [{

text: 'Add',
iconCls: 'add'
//handler: displayFormWindow
}],
bbar: new Ext.PagingToolbar({
pageSize: 6,
store: animalsDB,
displayInfo: true,
displayMsg: 'showing {0} - {1} of {2}',
emptyMsg: "SOMETHING IS VERY WRONG"
})
});
});Any suggestions and bashing welcome, Im not very good at this!

Thanks!

edit - firebug issue went away, other issues persist.

fruitwerks
12 Aug 2009, 9:41 PM
I'm only worried with the species column not displaying anything right now, like I said, it knows the data, as it displays if any column is sorted.

Thanks!

fruitwerks
13 Aug 2009, 3:16 PM
I simply had a typo and a dual declaration in my columns.

Everything works fine now

Thanks!