2012-05-10 16 views
2

私のビューにリストを表示できません。私のAjaxコールからデータが戻ってきているようです。 私は間違いなくここに何かがありません。助けてください。おかげリストが表示されない

詳細は以下のとおりです。 データ:

Stations.json

[ 
{ 
    "id": "129", 
    "stop": "NY Station", 
}, 
{ 
    "id": "13", 
    "stop": "Newark Station", 
} 

] 

モデル:

Ext.define('MyApp.model.Station', { 
extend: 'Ext.data.Model', 

config: { 
    fields: [ 
     {name: 'id', type: 'string'}, 
    {name: 'stop', type: 'string'} 

    ] 
} 

}); 

ストア:

 
     Ext.define('MyApp.store.Stations', { 
     extend : 'Ext.data.Store', 
     requires: ['MyApp.model.Station'], 
    id: 'stations', 
    xtype: 'stations', 
    config : { 
     model : 'MyApp.model.Station', 
     storeId: 'stationsStore', 
     autoLoad : true, 
     //sorters: 'stop', 
     proxy: { 
       type: 'ajax', 
       url: 'Stations.json' 

    } 
    }); 

ビュー:

Ext.define('MyApp.view.MyService', { 
extend: 'Ext.Panel', 
xtype: 'stationsformPage', 
fullscreen: true, 
layout: 'vbox', 
requires: [ 
    'MyApp.store.Stations',  
    'Ext.form.FieldSet', 
    'Ext.field.Password', 
    'Ext.SegmentedButton', 
    'Ext.List' 
    ], 

config: { 
    iconCls: 'settings', 
    title: 'My Service', 
    items: [ 
     { 
      docked: 'top', 
      xtype: 'toolbar', 
      title: 'My Service' 
     }, 

     { 
      xtype: 'list', 
      title: 'Stations', 
      store: 'stationsStore', 
      styleHtmlContent: true, 
      itemTpl: '<div><strong>{stop}</strong> {id}</div>' 

     }, 

    ] 
    }, 
    initialize: function() { 

     /* 
     Ext.Ajax.request({ 
      scope : this, 
      url: 'StationLocator.json', 
      callback : function(options, success, response){ 
        var json = Ext.decode(response.responseText); 
        alert(response.responseText); //this works 
        alert(json[0].stop); //this works 
      } 
     }); 
     */ 

    }//initialize 

    }); 

答えて

2

これをTabPanelに入れました。これは役に立ちますか?それは次のようになります。

enter image description here

ここに私の見解です:

 
Ext.define('MyApp.view.MyService', { 
    extend: 'Ext.tab.Panel', 
    xtype: 'stationsformPage', 
    fullscreen: true, 
    layout: { 
     pack: 'center' 
    }, 
    requires: [ 
     'MyApp.store.Stations', 
     'Ext.form.FieldSet', 
     'Ext.field.Password', 
     'Ext.SegmentedButton', 
     'Ext.List' 
    ], 
    config: { 
     tabBarPosition:'bottom', 
     layout: { 
      type: 'card', 
      animation: { 
       duration: 300, 
       easing: 'ease-in-out', 
       type: 'slide', 
       direction: 'left' 
      } 
     }, 
     fullscreen: true, 
     title: 'My Service', 
     items: [ 
      { 
       docked: 'top', 
       xtype: 'toolbar', 
       title: 'My Service' 
      }, 

      { 
       xtype: 'list', 
       title: 'Stations', 
       store: 'stationsStore', 
//    height: 600, 
//    width: 400, 
//    style: 'background-color: #c9c9c9;', 
       styleHtmlContent: true, 
       itemTpl: '{stop} {id}' 

      } 

     ] 
    } 

}); 




はここで、通常のパネルにリストを入れたバージョンです:

enter image description here

 
Ext.define('MyApp.view.MyService', { 
    extend: 'Ext.Panel', 
    xtype: 'stationsformPage', 
    fullscreen: true, 
    layout: { 
     pack: 'center' 
    }, 
    requires: [ 
     'MyApp.store.Stations', 
     'Ext.form.FieldSet', 
     'Ext.field.Password', 
     'Ext.SegmentedButton', 
     'Ext.List' 
    ], 
    config: { 

     fullscreen: true, 
    layout: 'fit', // Specifying fit is important. Won't see list without it 
     title: 'My Service', 
     items: [ 
      { 
       docked: 'top', 
       xtype: 'toolbar', 
       title: 'My Service' 
      }, 

      { 
       xtype: 'list', 
       store: 'stationsStore', 

       styleHtmlContent: true, 
       itemTpl: '{stop} {id}' 

      } 
     ] 
    } 
}); 
+0

ありがとうございます。しかし、パネルやフォームパネルではなぜそれは不可能ですか? – AbbIbb

+1

私はパネル溶液を加えました。何も表示されない場合は、デバッグに役立つ高さを与えるのに役立ちます。ビューが崩壊して見えないことがあります。 –

+0

@ user568866ありがとうございます!私は同じ問題を抱えていて、「レイアウト:「フィット」」の部分が問題でした! – CodeCanuck

関連する問題