私はカードレイアウトでセットアップされたSencha Touch 2.0アプリを持っています。ユーザーがクリックできるアイコンと顧客リスト(xtype: 'list')を含むダッシュボードが含まれています。アプリケーションがロードされると、私は顧客リストを含むアプリケーション内のすべての「カード」を読み込みますが、localStorage変数が設定されていない限り、データを(プロキシ経由で)ロードしません。すべてがロードされたら、localStorage変数をチェックしてユーザーが自動的にログインする必要があるかどうかを確認します。彼らが自動的にログインしている場合、私のアプリは完全に動作します。彼らがいない場合、私はそれらに "ログイン"カードを表示します。これは基本的にログインフォームです。このログをフォームに送信すると、私はajax呼び出しを実行します。これが正しく戻ったら、私はそれらを「ダッシュボード」カードに送ります。sencha touchのリストを動的に読み込む2
var tmpId = { id: example.id };
var cListStore = Ext.create('example.store.CustomerList');
cListStore.getProxy().setExtraParams(tmpid);
cListStore.load();
を、私は私のプロキシコールが起こっていることがわかります、と私は応答が正しいか確認することができ、上記のコードでは:しかし、その前に私が使用してAJAX呼び出しを介して顧客リストをロードしようとしています。しかし、ダッシュボードが表示され、Customersアイコンをクリックすると、空のリストが表示されます。私のツールバーはそこにあり、私のリストのindexBarもそこにあります。データはありません。私はここで何が間違っているのか分かりません。私は、このを見て、誰を助けることうまくいけば、私のリストビュー、ストア、および以下のモデルを含めています:
Ext.define('example.view.CustomerList', {
extend: 'Ext.Container',
id: 'customerListContainer',
xtype: 'customerlist',
config: {
layout: 'fit',
items: [{
xtype: 'toolbar',
docked: 'top',
title: 'Customers',
items: [{
xtype: 'button',
text: 'Home',
id: 'customerListHomeButton',
ui: 'back'
}]
}, {
xtype: 'list',
itemTpl: '<div class="contact">{first_name} <strong>{last_name}</strong> </div>',
store: 'CustomerList',
id: 'customer_list',
grouped: true,
indexBar: true
}]
}
});
Ext.define('example.store.CustomerList', {
extend: 'Ext.data.Store',
id: 'customerListStore',
requires: ['example.model.CustomerList'],
config: {
model: 'example.model.CustomerList',
sorters: 'last_name',
/*
* This actually makes the ajax request
*/
proxy: {
type: 'ajax',
url: '/example/api/customerList.php',
extraParams: {
id: example.id
},
reader: {
type: 'json'
}
},
autoLoad: ((example.id > 0) ? true : false), //only fetch the data if we have a id, or else we'll get an error from our api
/*
* Set the group headers to the first letter of the last name
*/
grouper: {
groupFn: function (record) {
return record.get('last_name')[0];
}
}
}
});
Ext.define('example.model.CustomerList', {
extend: 'Ext.data.Model',
config: {
/*
* Define the fields we get back from our ajax request
*/
fields: [
'first_name',
'last_name',
'address1',
'address2',
'city',
'state',
'zip_code',
'phone_daytime',
'phone_evening',
'phone_cell',
'email']
}
});
私も顧客リストストアにstoreIdを入れてみました、その後、代わりに次のコードを使用していますExt.create()を呼び出す:
Ext.StoreManager.get('storeid').load()
これは同じ結果をもたらしました。私はプロキシがデータを正しく取得しているのを見ることができましたが、それでも私のリストコンポーネントでレンダリングしていました。
まさに私が必要なもの! – seedg