PDA

View Full Version : Missing PropertyGrid.getStore().proxy



Hammit
17 Oct 2009, 3:50 AM
Hi all, very strange problem I've got here...

I've extended Ext.grid.PropertyGrid.
In it I set the store to a new Ext.data.JsonStore, which autoloads and has an id
of 'details-store'. I then instantiate the extended PropertyGrid and use it in my
layout, and it's fine. Shows the data from the server. Works good.

Problem: Reloading won't work. I get a this.proxy is null or not an object error.

To start with, the proxy seems to go missing after instantiation.


detailsPanel = new DetailsPanel({ rootPath: 'Ext-Test1' });
console.log("After instantiation: " + Ext.StoreMgr.lookup('details-store').proxy);

console.log("After instantiation: " + detailsPanel.getStore().proxy);


In this piece of code, the first log statement returns the proxy of the store as I would expect, but the second log statement gives me null.

Further investigation shows that the store itself is not the same in both of these calls,
which explains why the proxy is missing in the second. My guess is that the store is
getting re-created at some point instead of re-used. Is this correct...how do I avoid
this if it's the case and is this a bug in my code or an Ext problem?




var DetailsPanel = Ext.extend(Ext.grid.PropertyGrid, {

autoHeight: true,
enableColumnResize: true,


id: 'details-panel',



listeners: {
// Cancel editing - read only


beforeedit:


function(event) {
event.cancel = true;
}


},

store: new Ext.data.JsonStore({

autoLoad: true,
baseParams: {
rootPath: 'Ext-Test1'
},
fields: [
'URL',
'Revision',
'Root',
'Last Changed Rev',
{
convert: function(v, rec) {
var dt = new Date(Date.parseDate(Math.round(rec['Last Changed Date']), 'U'));
return dt.format('Y-m-d H:i:s A');
},
dateFormat: 'timestamp',
name: 'Last Changed Date',
type: 'date'
},
'Last Changed Author'
],




listeners: {
load:



function(store, records, options) {

console.log("load listener: " + store.proxy);

// get the property grid component
var propGrid = Ext.getCmp('details-panel');

// make sure the property grid exists

if (propGrid) {
// populate the property grid with store data
propGrid.setSource(store.getAt(0).data);
}
}
},
root: 'details',
storeId: 'details-store',
url: cgiRoot + '/details.pl'
}),
viewConfig: { forceFit: true }
});

Hammit
17 Oct 2009, 7:08 AM
Ok, here is a small, self-contained example demonstrating

http://www.extpaste.com/#2803

Hammit
18 Oct 2009, 1:57 AM
Ok, for those who experience the same problem, I'll put in here what I've
done to work around this problem. If any Ext developers see this, I honestly
think this is a good candidate for you to look into further, even though there
is a work-around. Truly looks like a bug!

Instead of reloading the data store by calling reload() on the store returned
by the getStore method of the PropertyGrid, I simply used the Ext.StoreMgr
to lookup the store.

Simple!

Why was the store in the PropertyGrid being replaced? Don't know.

Anyway, here is a pretty small and self-contained example demonstrating the
solution, with an obvious comment showing not what to do :)

http://www.extpaste.com/#2804

HTH