1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    19
    Vote Rating
    0
    anhnt3 is on a distinguished road

      0  

    Question How to dynamically load store for list which is inside panel

    How to dynamically load store for list which is inside panel


    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
    Code:
    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:
    Code:
    				this.getMain().push({
    							xtype : 'chapterlist',
    							title : record.data.nice_name,
    							data : record.data
    						});

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    19
    Vote Rating
    0
    anhnt3 is on a distinguished road

      0  

    Default


    Thanks very much.

Thread Participants: 1