私は ExtJS の学習であらゆる種類の問題を抱えています (私はフレックス開発者です)。現在、コマンドからストアをロードする方法がわかりません。サービス呼び出しを行ってデータを取得するコマンドがあります。次に、このデータを使用してモデルをロードします (コマンド内から)。
私のコード...
PhoneCallsLoadCommand.js: (コマンド)
Ext.define('DG.controller.PhoneCallsLoadCommand', {
extend: 'Ext.app.Controller',
stores: ['PhoneCalls'],
models: ['PhoneCall'],
views: [
'PhoneCallListView'
],
init: function () {
var url2 = "https://MyServiceURLWSDL";
var pl = new SOAPClientParameters();
pl.add("arg0", false);
SOAPClient.invoke(url2, "gePaymentsMethod", pl, true, getDataCallback);
function getDataCallback(response) {
// This is where I want to load the response data into the Model
var store = Ext.getStore('phoneCallsStore');
store.loadData(response);
}
}
});
サービス呼び出しから返された応答 XML データは次のとおりです。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dlwmin:getPaymentsMethod xmlns:dlwmin="http://blahblah.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<return>
<contents>
<eftAcctNo>501014635986</eftAcctNo>
<empSsn>122400724</eftAcctRoutNo>
</contents>
<contents>
<eftAcctNo></eftAcctNo>
<empSsn></eftAcctRoutNo>
</contents>
<contents>
<eftAcctNo></eftAcctNo>
<empSsn></eftAcctRoutNo>
</contents>
<status>0</status>
</return>
</dlwmin:getPaymentsMethod>
</soapenv:Body>
</soapenv:Envelope>
グリッドで使用できるように、この応答データをモデルに入力する必要があります。
PhoneCall.js: (モデル)
Ext.define('DG.model.PhoneCall', {
extend: 'Ext.data.Model',
config: {
idProperty: 'phoneCallModel',
fields: [
{name: "eftAcctNo", type: "string"},
{name: "empSsn", type: "string"}
]
}
});
PhoneCalls.js (ストア)
Ext.define('DG.store.PhoneCalls', {
extend: 'Ext.data.Store',
config: {
storeId: 'phoneCallsStore',
model: 'DG.model.PhoneCall',
autoLoad: false
},
proxy: {
type: 'memory',
reader: {
type: 'xml',
record: 'contents',
//rootProperty: 'return'
}
},
listeners: {
'load' : function() {
console.log("Making Service Call...");
}
}
});
コマンドで、これを行うと:
var store = Ext.getStore('phoneCallsStore');
store.loadData(response);
次のエラーが表示されます: Uncaught TypeError: Cannot call method 'loadData' of undefined
その応答データをモデルにロードする方法を教えてもらえますか? My View は、モデルを指すグリッドです。
PhoneCallListView.js (ビュー)
Ext.define('DG.view.PhoneCallListView' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.phoneCallListView',
title: 'Phone Calls DataGrid',
// we no longer define the Phone Calls store in the 'initComponent' method
store: 'PhoneCalls',
initComponent: function() {
this.columns = [
{header: 'Eft Acct No', dataIndex: 'eftAcctNo', flex:1},
{header: 'Emp Ssn', dataIndex: 'empSsn', flex:1},
];
this.callParent(arguments);
}
});
参考までに、ストアに ajax プロキシを使用してサービス呼び出しを行わせることができなかったので、soapclient.js を使用するのが簡単であることがわかりました。ありがとう