PDA

View Full Version : lazy instantiation of the store



whalethewise
26 Jan 2012, 7:58 AM
Hi

Is it possible to do lazy instantiation for the store when defining grid or combobox?

Something like
store: {
type: 'array',
id: 'cbstore,
autoLoad: false
}

Thanks

friend
26 Jan 2012, 10:30 AM
I used a functional test application, shoved an inline grid/store into an existing Tab panel, and it worked great:



Ext.ComponentQuery.query('tabpanel')[0].add({
xtype: 'grid',
title: 'Cities',
columns: [
{header: 'City', dataIndex: 'city', width: 200},
{header: 'PK ID', dataIndex: 'cityId', width: 90}
],
store: {
fields: [
{name: 'cityId', type: 'int'},
{name: 'city', type: 'string'}
],
autoLoad: true,
proxy: {
type: 'ajax',
url: 'city/listAll.action',
reader: {
type: 'json',
root: 'data'
}
}
}
})


This also worked:



Ext.ComponentQuery.query('tabpanel')[0].add({
xtype: 'grid',
title: 'Cities',
columns: [
{header: 'City', dataIndex: 'city', width: 200},
{header: 'PK ID', dataIndex: 'cityId', width: 90}
],
store: {
fields: [
{name: 'cityId', type: 'int'},
{name: 'city', type: 'string'}
],
data: [
{cityId: 271, city: "Allens"},
{cityId: 1, city: "Andrews"},
{cityId: 2, city: "Apison"},
{cityId: 3, city: "Athens"}
]
}
})

whalethewise
26 Jan 2012, 11:01 AM
Thank you