0

私は 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 を使用するのが簡単であることがわかりました。ありがとう

4

2 に答える 2

0

行:Uncaught TypeError: Cannot call method 'loadData' of undefinedあなたの店が定義されていないことを教えてくれます。あなたのストアは と呼ばれているので、コントローラーで構成を使用していることを確認して、 をDG.store.PhoneCalls使用する必要があります。Ext.getStore('PhoneCalls')stores: ['PhoneCalls']

また、Ajax プロキシーを使用すると問題が発生する場合がありますが、Ajax プロキシーを機能させる方法を実際に見つけてみてください。ここでストアをロードしようとしている方法は、非常にハックです。おそらく、XmlStore使用すべきものは次のとおりです: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.XmlStore

于 2013-07-16T11:18:44.883 に答える
0

これは私のために働いたものです:

    function getDataCallback(req, r) {
        var store = Ext.getStore('PhoneCalls');
        store.loadRawData(r);
        store.sync();
    }
于 2013-08-02T13:28:01.833 に答える