2012-03-16 20 views
5

Sencha Touch 2 listesinde görünmesi için gerçek veriler elde etme konusunda sorun yaşıyorum. Liste bir JSONP yanıtıyla doldurulmalı ve 2 satırın gösterilmesini bekliyorum. Bunun yerine, 'null at null' ile bir satır alırım.Sencha Touch 2 - JSONP proxy yardımı, şablonun her zaman değeri sıfırdır

http://some-server/data-fetcher.php?_dc=1331910031292&events=true&page=1&start=0 
    &limit=25&callback=Ext.data.JsonP.callback1 

İşte JSONP tepkidir:

İşte
Ext.data.JsonP.callback1({"data":[{"id":"4","name":"Sample Name 1", 
    "description":null,"location":"Sample Location 1", 
    "start_time":"2012-03-22 00:00:00","end_time":null},{"id":"5", 
    "name":"Sample Name 2","description":null,"location":"Sample Location 2", 
    "start_time":"2012-03-31 00:00:00","end_time":null}],"num_rows":2}); 

modelim var: Burada

gönderilen alır URL

Ext.define('MyApp.store.EventsOnline', { 
    extend : 'Ext.data.Store', 
    requires: ['MyApp.model.Event'], 
    config : { 
     model : 'MyApp.model.Event', 
     autoLoad : true, 
     proxy : { 
      type : 'jsonp', 
      url : 'http://some-server/data-fetcher.php', 
      reader : { 
       type : 'json', 
       root : 'data', 
       totalCount : 'num_rows' 
      }, 
      callbackKey : 'callback', 
      extraParams : { 
       'events' : true 
      } 
     } 
    } 
}); 
:

İşte
Ext.define('MyApp.model.Event', { 
    extend: 'Ext.data.Model', 
    config : { 
     idProperty: 'id', 
     fields : [ { 
      name : "id", 
      type : "int" 
     }, { 
      name : "name", 
      type : "string" 
     }, { 
      name : "description", 
      type : "string" 
     }, { 
      name : "location", 
      type : "string" 
     }, { 
      name : "start_time", 
      type : "date" 
     }, { 
      name : "end_time", 
      type : "date" 
     } ] 
    } 
}); 

dükkanım var

Sample Name 1 at Sample Location 1 
Sample Name 2 at Sample Location 2 

Ve bunun yerine tek gördüğüm ise:

Ext.define('MyApp.view.Event', { 
    extend: 'Ext.Container', 
    config : { 
     layout : { 
      type : 'vbox', 
      align : 'stretch' 
     }, 
     fullscreen : true, 
     flex : 1, 
     items : [ 
      { 
       xtype : 'toolbar', 
       docked : 'top', 
       title : 'Events' 
      }, { 
       xtype : 'list', 
       flex : 1, 
       store : 'EventsOnline', 
       itemTpl : '{name} at {location}' 
      } 
     ] 
    } 
}); 

Ne listemde görmeyi beklediğiniz geçerli:

null at null 

yanlış yapıyorum

İşte benim bakış var ?

Düzenleme: Bu konularda, burada benim app ve denetleyici şunlardır:

Ext.Loader.setConfig({enabled : true}); 

Ext.application({ 
    name    : 'MyApp', 
    appFolder   : 'app', 
    controllers : ['Home'], 
    launch : function() { 
     window[this.getName()].app = this; 
    } 
}); 

Ext.define('MyApp.controller.Home', { 
    extend: 'Ext.app.Controller', 
    models: ['Event'], 
    stores: ['EventsOnline'], 
    views: ['Event'], 
    init: function() { 
     var me = this; 
     Ext.Viewport.add(Ext.create('MyApp.view.Event')); 
    } 
}); 

cevap

3
root : 'data', 
totalCount : 'num_rows' 

kullanımdan kaldırıldı mı. Kullanın:

rootProperty: 'data', 
totalProperty: 'num_rows' 

gelişimi için sencha-touch-all-compat.js dan emin dahil Sencha'sı dokunun olun. Tarayıcı konsolunda kullandığınız tüm kullanım dışı şeyleri rapor eder.

+0

Arrrrgh, öyleydi. Bütün gün kafamı çarptıktan sonra, bununla daha iyi şansa sahip olup olmadığımı görmek için jQuery Mobile'a geçtim. Sheesh, belki şimdi Sencha Touch 2'ye geri döneceğim. Onlara “göz ardı edilmemesi” anlamına gelen “tamamıyla” anlamına gelir. Artık pek çok Sencha Touch öğreticisi buluyorum, çünkü artık v2 kullanımdan kaldırıldı/kaldırıldı. –

+1

Bunun için bir gün israf etti, teşekkürler. Geriye doğru uyumluluk! – SteveCav

0

Ayrıca, listemi görüntülemeyi ve bu konuyla ilgili arama yapmayı da deniyordum.

Son olarak bence bu değiştirdikten sonra cevabımı aldım:

extend: 'Ext.Container', 

extend:'Ext.navigation.View', 

için aşağıda örnek bağlantısından yukarıdaki ipucu! Artık çalışan

Sencha Touch 2: data intigration or how to share dynamic information between sencha and javascript

, benim ilk MVC örneği çalışma görmekten mutlu

:) o birine yardım umuyoruz.

İlgili konular