sencha touch - Can't get data from store to show up as the model -
i'm kinda new sencha touch, please bear me.
at app's launch set viewport viewport use, , set views app namespace.
launch: function() { this.views.viewport = new this.views.viewport(); this.views.homecard = this.views.viewport.getcomponent('home'); this.views.usercard = this.views.viewport.getcomponent('user'); this.views.infocard = this.views.viewport.getcomponent('info'); }
the viewport loads home view first, , here meet problem. homecard:
toolbardemo.views.homecard = ext.extend(ext.panel, { title: "meny", iconcls: "home", scroll: "vertical", bodystyle: "background-color: #ffffff !important; background-image: url(images/background.png) !important; background-repeat:no-repeat; background-position:bottom left;", initcomponent: function() { toolbardemo.views.homecard.superclass.initcomponent.apply(this, arguments); }, store:toolbardemo.stores.feedstorer, tpl:buttontemplate, dockeditems: [ { xtype: "toolbar" } ], defaults: {height: "110px"}, });
here's template:
var buttontemplate = new ext.template ( '<tpl for=".">', ' <div class="home_button_container">', ' <img class="home_button" src="{url_icon_large}" />', ' <p class="home_button_text">{name}</p>', ' </div>', '</tpl>' );
here's model:
ext.regmodel('feeds', { fields: [ {name: 'name', type: 'string'}, {name: 'url_icon_small', type: 'string'}, {name: 'url_icon_medium', type: 'string'}, {name: 'url_icon_large', type: 'string'}, {name: 'url_icon_large_p', type: 'string'}, {name: 'url', type: 'string'}, {name: 'sort_order', type: 'string'} ] });
here's store:
toolbardemo.stores.feedstore = new ext.data.store({ model: 'feeds', storeid: 'feedstore', proxy: { type: 'scripttag', url : 'http://localhost/webservice/feeds.php?username=' + susername + '&password=' + spassword, reader: { type: 'json', root: 'feeds' } }, autoload: true });
here's json:
{"feeds":[{"name":"links","url_icon_small":"http:url/link_small.png","url_icon_medium":"url/link_medium.png","url_icon_large":"url/link_large.png","url":"url/feed_content.php?type=link","sort_order":"1"}],"updated":[{"last_updated":"2011-06-09 11:15:47"}]}
the problem nothing shows on view, , suspect may wrong model? i've logged store , can see gets data should.
anyone got suggestion fix this?
thanks in advance
edit (got tip dataview): ext.panel change:
toolbardemo.views.homecard = new ext.panel({ title: "meny", iconcls: "home", scroll: "vertical", bodystyle: "background-color: #ffffff !important; background-image: url(images/background.png) !important; background-repeat:no-repeat; background-position:bottom left;", initcomponent: function() { toolbardemo.views.homecard.superclass.initcomponent.apply(this, arguments); }, dockeditems: [ { xtype: "toolbar" } ], defaults: {height: "110px"}, items: new ext.dataview( { tpl:buttontemplate, store: toolbardemo.stores.feedstorer, autoheight:true, multiselect: true, loadingtext: 'laster data', itemselector:'div.home_button_container', emptytext: 'no images display' }) });
this setup handled ext.dataview
, not ext.panel
. inheriting form ext.component
can passed data
, tpl
parameter , cause body loaded result of passing data tpl.
you using store
handle data not built ext.panel
class. if convert ext.dataview
, define required parameters necessary (it throw errors when try creating 1 without parameters necessary), template / panel display properly.
Comments
Post a Comment