-1

我下载了几个实体一个 ajax 请求。然后我将它们添加到商店。我需要提交一个类似于 ajax 请求的更改。如何正确地做到这一点?

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']);
}
4

2 回答 2

0

好吧,您可以将其作为 JSON 发送,并且可以按如下方式轻松完成:

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

如果您想在商店中使用,请使用autoModelfield 的类型。这种类型可以包含任何对象。

检查以下参考资料:

ExtJs 4.0.7 商店

ExtJs 3.4.0 商店

请检查autoSync属性以在每次编辑其记录后自动将存储与其代理同步。默认为假。

于 2013-08-18T10:28:57.770 回答
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);   
  });
}
于 2013-08-20T06:16:45.820 回答