2016-04-01 9 views
1

呼び出す時々保存:ExtJSには、我々はExtJSに4.2で、次の店を持って作成する代わりに、更新

Ext.define('Example.store.BasketDocuments', { 
    extend: 'Ext.data.Store', 
    model: 'Example.model.Document', 
    autoLoad: true, 
    autoSync: true, 
    sorters: [ 
    { 
     property: 'doc_type', 
     direction: 'ASC' 
    } 
    ], 
    proxy: { 
    type: 'rest', 
    url: baseUrl + 'document_basket', 
    headers: { 
     'Accept': 'application/json', 
     'Content-Type': 'application/json;charset=utf-8' 
    }, 
    reader: { 
     type: 'json', 
     root: 'items' 
    }, 
    writer: { 
     type: 'json' 
    }, 
    actionMethods: {create: "POST", read: "GET", update: "PUT", destroy: "DELETE"} 
    } 
}); 

それは、ドラッグして、グリッドに接続し、ドロップ機能をされています。

我々はすぐに店を更新してしまうグリッドに(それが動作9用)の周りに10個のファイルをドラッグすると、我々は

/api/document_basket/1964?_dc=1459498608890&{} 

のようなURLにPOST機能を実装していないので、我々は、サーバーエラーを取得しますこれは1つのエントリのみです。

他人のためにそれが動作します

/api/document_basket?_dc=1459498608941&{} 

だろう。

単一のエントリだけをドラッグすると動作します。

したがって、ExtJSはURLにIDを持つPOSTリクエストを送信していますが、代わりにPUTである必要がありますか?何故ですか?

答えて

0

これは私のプロジェクトで修正できました。

理由は、私はループ内でストアにアイテムを追加していたため、それぞれの追加後に、14個のファイルを追加した後に同期が行われました。

これは、1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14という105件のリクエストがあることを発見しました。

onBeforeDropItem: function (node, data, overModel, dropPosition, dropHandlers, eOpts) { 
    dropHandlers.cancelDrop(); 

    var store = Ext.getStore('BasketDocuments'); 

    store.suspendAutoSync(); // new 

    if (node.id != 'documenttreepanel-body') { 
     Ext.Array.each(data.records, function (r, index) { 
      r = r.copy(); 
      r.phantom = true; 
      r.data.id = null; 
      r.data.download_size = 1; 
      r.data.download_type = 1; 

      if (r.data.doc_type == 1) { 
       if (r.data.count == 0) { 
        Ext.create('Ext.window.MessageBox').show({ 
         title: Ext.ux.Translate.get('Info'), 
         msg: Ext.ux.Translate.get('Ordner') + '<b>' + r.data.name + '</b>' + Ext.ux.Translate.get(' Is empty and cannot be added ') + '.', 
         buttons: Ext.Msg.OK, 
         modal: true 
        }); 
       } else { 
        store.add(r); 
       } 
      } else { 
       store.add(r); 
      } 
     }); 
    } 

    store.sync(); // new 
    store.resumeAutoSync(); // new 

ソリューションは、ループの前に同期を無効にすることです

関連する問題