PDA

View Full Version : GridPanel using a defined Store Problem



muselmanach
4 Jan 2012, 7:46 AM
I can't get this one working.
I have to use the Ext.define for store, so its global.

I get: "TypeError: item is undefined"

using:


Ext.define('js_model_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid', {
extend: 'Ext.data.Model',
fields: [{
type: 'string',
name: 'id'
},{
type: 'string',
name: 'displayField'
}]
});


Ext.define('js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid',{
extend: "Ext.data.Store",
storeId: "testdata",
proxy:new Ext.data.proxy.Memory({
model:'js_model_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid',
reader:new Ext.data.reader.Json({})
}),
model:'js_model_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid',
data:[{
id:1,
displayField:'Vienna'
},{
id:2,
displayField:'London'
},{
id:3,
displayField:'New York'
}],
remoteSort:false
});

new Ext.grid.Panel({
id:'viewport.tab.tests_ui_objects_Ext_Mixed__form.fieldset.grid',
autoScroll:true,
xtype:'grid',
closable:false,
title:'grid datasource',
autoHeight:true,
columns:[{
id:'viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid_id',
width:40,
sortable:true,
dataIndex:'id',
text:'id'
},{
id:'viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid_displayField',
width:120,
sortable:true,
dataIndex:'displayField',
text:'city',
editor:{
allowBlanke: false
}
}],
forceFit:true,
store:'testdata',
loadMask:true,
name:'grid',
renderTo: Ext.getCmp("viewport.tab.form")
});

mitchellsimoens
4 Jan 2012, 8:04 AM
Some constructive feedback


Your class names are bad. Your store is 'js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid', your name should be descriptive but short. You should be able to glance at it and tell what it is.
id should only be used for debugging, you have it on everything and relying on it will be hard to change it later on.


So the issue I saw is that your store isn't put in the StoreManager. If you change this line in your grid it will work:


store:'testdata',

to


store: new js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid(),

muselmanach
4 Jan 2012, 8:19 AM
big thx

its working now

mitchellsimoens
4 Jan 2012, 8:35 AM
That's because you're using Ext.getCmp which returns a component on the renderTo config which expects a DOM element or the id of a DOM element