PDA

View Full Version : How to dynamically load store for list which is inside panel



anhnt3
19 Mar 2012, 3:43 AM
I have an list which is nested insde a Panel. And i want to dynamically load store to list but it not worked, the list loaded the store but is not displayed. Please help me:

My panel which the list is nested


Ext.define('DftComic.view.chapter.ChapterList', {
extend : 'Ext.Panel',
xtype : 'chapterlist',


config : {
tpl : '{chapters_json_url}',
items : [{
xtype : 'panel',
html : 'panel inside panel'
}, {
xtype : 'list',


config : {
onItemDisclosure : true,
autoDestroy : true,
store : 'Chapters',
cls : 'chapterlist',


itemTpl : [
'<div class="field_container">',
'<div class="field_rep_img_url"><img src="{rep_img_url}&mode=thumbnail" / ></div>',
'<div class="field_nice_name">{nice_name}</div>',
'</div>'].join('')
}


}]


},
initialize : function() {
this.callParent();
var list = this.child('list');


var me = this;
var store = Ext.getStore('Chapters');
store.getProxy()._url = me.getData().chapters_json_url;


// the list load the store but it not displayed
list.setStore(store);
list.refresh();
list.show();


// another try, but it not worked
// store.load({
// scope : this,
// callback : function(records, operation, success) {
// var items = [];
// store.each(function(rec) {
// // items.push({
// // xtype : 'panel',
// // html : ['<img src="',
// // rec.data.img_url,
// // '"/>'].join(''),
// // scrollable : 'vertical'
// //
// // });
// console.log(rec.data);
// items.push({
// // xtype : 'panel',
// // data : rec.data,
// // title : rec.data.no
// html : 'test'
// });
// });
//
// me.setItems(items);
// console.log(items)
// me.setActiveItem(0);
// }
// });


}


})


And the code which call:

this.getMain().push({
xtype : 'chapterlist',
title : record.data.nice_name,
data : record.data
});

mitchellsimoens
19 Mar 2012, 10:38 AM
Your list doesn't know what height to have. Either give it a height or use some layout on your panel that can manage it's height.

anhnt3
19 Mar 2012, 11:58 PM
Thanks very much.