【发布时间】:2014-04-18 01:32:16
【问题描述】:
我有一个商店配置了一个代理到服务器的POST 数据。我动态地将记录添加到这个商店。在 store 上调用 sync() 方法后,数据被发送到服务器。但是查看网络流量,我发现发送了整个记录数据。如何将商店配置为仅发送个人数据(例如仅发送记录的 ID)?
我尝试在连接到代理的 JSON 写入器上将 WriteAllFields 属性设置为 false,但这没有帮助
我也尝试过这种方法:Ext.JS Prevent Proxy from sending extra fields 但请求甚至没有执行
var documentStore = Ext.getStore('Document');
var trashStore = Ext.getStore('TrashDocuments');
documentStore.each (function(record) {
console.debug(record);
//record.phantom = true;
//record.setDirty();
trashStore.add(record);
documentStore.remove(record);
});
var newWriter = Ext.create('Ext.data.writer.Json',{
getRecordData: function(record){
return {'id':record.data.id};
}
});
trashStore.getProxy().setWritter(newWritter);
trashStore.sync({
success: function()
{
console.debug("success!!");
},
failure: function()
{
console.debug("failed...");
},
callback: function()
{
console.debug("calling callback");
},
scope: this
});
console.debug("END");
【问题讨论】:
-
你是如何修改记录的?你有没有机会在上面设置脏标志?
-
我将记录从另一个商店添加到此商店,然后调用 sync()
标签: javascript extjs store