PDA

View Full Version : Problems refreshing Panel upon store is loaded



dionisexorcius
22 Feb 2009, 6:42 AM
Hello,

1. I have problems with following problem:

I have store configured as JsonStore
DataView using specified store and template
Panel using configured DataView to load its content.Problem: upon loading of store (which gets loaded - checked with "load" handler), panel doesn't update its content.

Code:

var store = new Ext.data.JsonStore({
url: 'http://localhost:8080/Generator/getData',
root: 'results',
fields: [ 'id', 'content' ]
});
store.load();

// template
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div>{content}</div>',
'</tpl>'
);

var dataView = new Ext.DataView({
store: store,
tpl: tpl,
autoHeight:true,
overClass:'x-view-over',
emptyText: 'No content to display'
});

// panel
var panel = new Ext.Panel({
id:'display-panel',
frame:true,
width:535,
autoHeight:true,
autoScroll:true,
collapsible:true,
layout:'fit',
title:'Simple DataView',
items: dataView
});
panel.render(document.body);

2. Additional question:
If I use simple Store in order to populate Panel with one of its properties ('content') in store's "load" handler, like here:

var content = Ext.getCmp('MyPanel').getEl();
content.dom.innerHTML = store.reader.jsonData.results.content;

my Panel presents data but if content is longer I don't have scrolling enabled (though I placed autoScoroll:true in panel definition).

Do you have any proposition how to enable scrolling?

Thanks at advance!

dionisexorcius
22 Feb 2009, 7:44 AM
Hello,

I have solved problem with above code.
For anyone that has similar problems I will describe how, so I hope this can spear your time if you made mistake in same place as I did.

Use following in order to display data correctly(you need to inform template about correct path to data retrieved):

tpl.overwrite(panel.body, store.reader.jsonData.results);


Bye!