PDA

View Full Version : Data-bound panel for a single record



atwoodjw
2 May 2011, 4:39 PM
What is the best way to create a data-bound panel for a single record? DataView's seem geared towards displaying a collection of records, not a single record. I'd like to tie the panel's load mask into the (lazy) loading of a single record.

Here's what I've come up with so far.


app.views.widget.RichText = Ext.extend(Ext.Panel, {
id: 'richText',
layout: 'fit',
styleHtmlContent:true,
scroll: 'vertical',
itemSelector: 'div.richText',
tpl: new Ext.XTemplate('<tpl for=".">', '<div class="richText">', '<div>{data}</div>', "</div>", "</tpl>", '<div class="x-clear"></div>'),
listeners: {
afterrender: function() {
Ext.getCmp('richText').setLoading(true);
}
},
initComponent: function() {
app.views.widget.RichText.superclass.initComponent.apply(this);

...

var richText = page.load('1', {
success: function(record, operation) {

Ext.getCmp('richText').update(record.data);
Ext.getCmp('richText').setLoading(false);
}
});
}
}
});