2012-03-01 3 views
0

用のリモートサーバーからデータを取得し、私は店を作成しました:カレンダーイベント

Ext.regStore('EventCalendarStore',{ 
model: 'EventCalendar', 
proxy:{ 
    type:'ajax', 
    url:url, 
    reader:{ 
     type:'json' 
    } 
}, 
    autoLoad:true 
}); 

EventsApp.stores.eventCalendarStore = Ext.StoreMgr.get('EventCalendarStore'); 

これは、JSON形式でデータを格納します。

私はExt.ux.TouchCalendarViewカレンダーを使用しています。このカレンダーは、作成した店舗構造とは異なる方法でデータを受け取ります。私はこのカレンダーのために別のストアを作成し、適切な方法でフォーマットをレンダリングする必要が理由です

var eventStore = new Ext.data.Store({ 
    model: 'Event', 
    data: [{ 
     event: 'Breaking Development 2011', 
     location: 'Nashville', 
     start: new Date(2011, 8, 12), 
     end: new Date(2011, 8, 14) 
    }, { 
     event: 'TechCrunch Disrupt SF', 
     location: 'San Francisco', 
     start: new Date(2011, 8, 12), 
     end: new Date(2011, 8, 14) 
    }, { 
     event: 'ATypl Reykjavik 2011', 
     location: 'Reykjavik', 
     start: new Date(2011, 8, 14), 
     end: new Date(2011, 8, 18) 
    }, { 
     event: 'Do Wales 2011', 
     location: 'Cardigan', 
     start: new Date(2011, 8, 14), 
     end: new Date(2011, 8, 18) 
    }, { 
     event: 'Future of Mobile', 
     location: 'London', 
     start: new Date(2011, 8, 16), 
     end: new Date(2011, 8, 16) 
    }, { 
     event: 'WindyCityRails 2011', 
     location: 'Chicago', 
     start: new Date(2011, 8, 17), 
     end: new Date(2011, 8, 17) 
    }, { 
     event: 'CapitoUS', 
     location: 'Washington DC', 
     start: new Date(2011, 8, 18), 
     end: new Date(2011, 8, 18) 
    }, { 
     event: 'Strange Loop 2011', 
     location: 'St Louis', 
     start: new Date(2011, 8, 18), 
     end: new Date(2011, 8, 20) 
    }, { 
     event: 'Frozen Rails 2011', 
     location: 'Helsinki', 
     start: new Date(2011, 8, 20), 
     end: new Date(2011, 8, 21) 
    }, { 
     event: 'Web Accessibility', 
     location: 'London', 
     start: new Date(2011, 8, 21), 
     end: new Date(2011, 8, 21) 
    }, { 
     event: 'onGameStart', 
     location: 'Warsaw', 
     start: new Date(2011, 8, 22), 
     end: new Date(2011, 8, 23) 
    }, { 
     event: 'Improving Reality', 
     location: 'Brighton', 
     start: new Date(2011, 8, 23), 
     end: new Date(2011, 8, 23) 
    }, { 
     event: 'Android Homecoming', 
     location: 'Mountain View', 
     start: new Date(2011, 8, 23), 
     end: new Date(2011, 8, 25) 
    }, { 
     event: 'Mobilize', 
     location: 'San Francisco', 
     start: new Date(2011, 8, 26), 
     end: new Date(2011, 8, 27) 
    }, { 
     event: 'Accessibility Summit', 
     location: 'Online', 
     start: new Date(2011, 8, 27), 
     end: new Date(2011, 8, 27) 
    }, { 
     event: 'UX Web Summit', 
     location: 'Online', 
     start: new Date(2011, 8, 28), 
     end: new Date(2011, 8, 28) 
    }, { 
     event: 'Modernizer with Faruk Ates', 
     location: 'San Francisco', 
     start: new Date(2011, 8, 29), 
     end: new Date(2011, 8, 29) 
    }, { 
     event: 'Creative JavaScript and HTML5', 
     location: 'Brighton', 
     start: new Date(2011, 8, 29), 
     end: new Date(2011, 8, 30) 
    }, { 
     event: 'UX Camp Brighton', 
     location: 'Brighton', 
     start: new Date(2011, 9, 1), 
     end: new Date(2011, 9, 1) 
    }, { 
     event: 'Future of Web Apps', 
     location: 'London', 
     start: new Date(2011, 9, 3), 
     end: new Date(2011, 9, 5) 
    }, { 
     event: 'droidcon 2011', 
     location: 'London', 
     start: new Date(2011, 9, 6), 
     end: new Date(2011, 9, 7) 
    }, { 
     event: 'PHP NW 2011', 
     location: 'Manchester', 
     start: new Date(2011, 9, 7), 
     end: new Date(2011, 9, 9) 
    }, { 
     event: 'O\'Reilly Android Open Conference', 
     location: 'San Francisco', 
     start: new Date(2011, 9, 9), 
     end: new Date(2011, 9, 11) 
    }, { 
     event: 'Web 2.0 Expo/NY', 
     location: 'New York', 
     start: new Date(2011, 9, 10), 
     end: new Date(2011, 9, 13) 
    }, { 
     event: 'Sencha Con', 
     location: 'Austin, Texas', 
     start: new Date(2011, 9, 23), 
     end: new Date(2011, 9, 26) 
    }, { 
     event: 'Future of Web Design', 
     location: 'New York', 
     start: new Date(2011, 10, 7), 
     end: new Date(2011, 10, 9) 
    }, { 
     event: 'Build', 
     location: 'Belfast', 
     start: new Date(2011, 10, 7), 
     end: new Date(2011, 10, 11) 
    }, { 
     event: 'Heart & Sole', 
     location: 'Portsmouth', 
     start: new Date(2011, 10, 18), 
     end: new Date(2011, 10, 18) 
    }] 
}); 

。私はこのように店を作り直しています:

EventsApp.stores.eventCalendarStore.load(function(){ 
    EventsApp.stores.eventCalendarStore.each(function(record){ 

     var dateS = record.data.startTime; 
     var dateE = record.data.endTime; 

     var converterEndTime = new Date(); 
     var converterStartTime = new Date(); 
     var startT = new Object(); 
     var endT = new Object(); 

     if(typeof dateS =='string') { 
      converterStartTime = new Date(dateS.substr(0,10)*1000); 

     }else { 
      converterStartTime = new Date(dateS); 
     } 


     if(typeof dateE =='string'){ 
      converterEndTime = new Date(dateE.substr(0,10)*1000); 
     }else{ 
      converterEndTime = new Date(dateE); 
     } 
     endT = converterEndTime.format("Y , n, j"); 
     startT = converterStartTime.format("Y , n, j"); 
     var cStore = EventsApp.stores.eventCalendarOfflineStore; 
     cStore.add({ 
      event:record.data.name, 
      location:record.data.notes, 
      start:new Date(startT), 
      end:new Date(endT) 
     }); 
     cStore.sync(); 
     record.save(); 
    }); 
}); 

しかし、データは最初の店から2番目の店に転送されていません。

データを2番目のストアに転送するにはどうすればよいですか?または、他の方法でカレンダーに最初の店からのデータを与える方法はありますか?

答えて

0

遅くなりません。あなたの質問に答えるために、HTTPキャッシングを利用して、2番目のストアのinit関数でストアをロードすることができます。キャッシュされているため、データはネットワーク転送なしでそこに保存されます。

関連する問題