2011-07-01 9 views
0

私はSencha Touchを少し新しくしていますので、私にご負担ください。店舗からのデータをモデルとして表示することができません

アプリの起動時に私は使用するビューポートにビューポートを設定し、すべてのビューをアプリ名前空間に設定します。

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'); 
} 

ビューポートが最初にホームビューを読み込み、ここで問題が発生します。 これは私の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"}, 

}); 

は、ここに私のテンプレートです:

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>' 
); 

はここに私のモデルです:

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'} 
    ] 
}); 

ここに私の店です:

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 
}); 

ここでJSONです:

{ "フィード":[{ "名": "リンク"、 "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" 秒}]}

問題は、何もこのビューに示さないということである、と私はそれがモデルと間違って何か得ることを疑いますか? 私はストアを記録しており、私はそれが必要なデータを取得することがわかります。

誰でもこの問題を解決するための提案がありますか?事前

おかげ


EDIT(データビューについてのガットの先端): Ext.Panelの変更:

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 to display' 
    }) 
}); 

答えて

0

これは、現在Ext.Dataviewとしないことによって処理されるように設定されExt.Panel。フォームExt.Componentを継承したものは、datatplのパラメータを渡して、データをtplに渡した結果をボディにロードさせることができます。

しかし、Ext.Panelクラスに組み込まれていないデータを処理するには、storeを使用しています。 Ext.Dataviewに変換し、必要なパラメータを必要に応じて定義すると(必要なすべてのパラメータを設定せずにエラーを生成すると)、テンプレート/パネルが正しく表示されます。

+0

こんにちは、答えに感謝します。私はそれをデータビューに変更し、tpl、store、およびitemSelectorを私に与えようとしましたが、errormessageを与え続けます: "キャッチされていないDataViewはtpl、storeおよびitemSelectorの設定を定義する必要があります。私は最初の投稿を編集しているので、私は何をしているのか見ることができます。 – Ikky

+0

Ext.Dataviewインスタンス化のtplパラメータを空文字列に設定しようとしましたか? – Ballsacian1

+0

私は移動しなければならなかったので、DataViewを破棄して何かを試しました – Ikky

関連する問題