2013-08-18 65 views
-1

我下載了幾個實體一個ajax-request。然後我將它們添加到商店。我需要提交一個類似於ajax-request的更改。如何正確地做到這一點?ExtJS中的嵌套數據

JSON結構:

{ 
    entity1: [], 
    entity2: [], 
    entyty3: [] 
} 


success: function(responce) { 
    var data = Ext.decode(response.responseText); 
    store1.add(data['entity1']); 
    store2.add(data['entity2']); 
    store3.add(data['entity3']); 
} 
+0

存儲類型在這裏不清楚。它是JsonStore嗎? –

+0

建議用更多細節來描述問題。比如你如何提交,存儲定義等。 –

回答

0

好了,你可以把它作爲JSON和如下,可以很容易做到:

Ext.Ajax.request({ 
    url: 'YourURL', 
    jsonData: YourObjectRef, // can be any object/array or JSON string 
    success: function(response, opts) { 
     // your code 
    } 
}); 

如果你想用店裏做它用爲Modelfield輸入auto。這種類型可以包含任何對象。

檢查以下參考資料:

ExtJs 4.0.7 Stores

ExtJs 3.4.0 Stores

請檢查autoSync屬性,以每個編輯它的記錄之一後,自動同步,其代理的商店。默認爲false。

+0

我只需要發送更改的記錄。如果服務器將分配ID添加記錄並返回更改,該怎麼辦? – user2417329

0

你可以這樣使用。因爲在extjs4中,有必要使用該模型創建一個記錄

success: function(responce) { 
    var data = Ext.decode(response.responseText),record; 
    Ext.each(data,function(entity,index,dataItself){ 
     record = Ext.create('YOURMODEL',entity); 
     store.add(record); 
    }); 
}