Javascript ExtJS。Ext.data.DirectStore在网格更新后向服务器发送空数据
我在将数据从Ext.data.DirectStore保存到服务器时遇到问题 这是我的密码:Javascript ExtJS。Ext.data.DirectStore在网格更新后向服务器发送空数据,javascript,extjs,Javascript,Extjs,我在将数据从Ext.data.DirectStore保存到服务器时遇到问题 这是我的密码: new Ext.data.DirectStore({ api: { read: AbonApi.cities, create: AbonApi.cities_create, update: AbonApi.cities_update, destroy: AbonApi.cities_destroy }, paramsA
new Ext.data.DirectStore({
api: {
read: AbonApi.cities,
create: AbonApi.cities_create,
update: AbonApi.cities_update,
destroy: AbonApi.cities_destroy
},
paramsAsHash: false,
autoSave: false,
storeId: 'cities-store',
reader: new Ext.data.JsonReader({
root: 'data',
idProperty: 'id',
fields: [
'id',
'name',
'label',
'comment',
]
}),
writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: true,
listful: true
})
});
Ext.ux.CityGrid = Ext.extend(Ext.grid.EditorGridPanel,{
initComponent: function(){
var config = {
frame:true,
title: 'Cities',
height:200,
width:500,
store: 'cities-store',
closable: true,
tbar: [{
text: 'Apply',
handler: function() {
this.store.save()
},
scope: this
}],
columns: [
{header: "Id", dataIndex: 'id', editor: new Ext.form.TextField()},
{header: "Name", dataIndex: 'name', editor: new Ext.form.TextField()},
{header: "Label", dataIndex: 'label', editor: new Ext.form.TextField()},
{header: "Comment", dataIndex: 'comment', editor: new Ext.form.TextField()},
],
onRender:function() {
Ext.ux.CityGrid.superclass.onRender.apply(this, arguments);
this.store.load();
}
}
Ext.apply(this, Ext.apply(this.initialConfig, config));
Ext.ux.CityGrid.superclass.initComponent.apply(this, arguments);
}
});
编辑网格后,按下Apply
按钮,我可以在firebug中看到这样的POST数据:
{"action":"AbonApi","method":"cities_update","data":null,"type":"rpc","tid":7}
为什么数据
为空,我对网格的更改在哪里?
我做错了什么,或者这是个错误
更新:
Ext.ux.CityGrid
... cutted out ...
tbar: [{
text: 'Apply',
handler: function() {
modified = this.store.getModifiedRecords();
console.log(modified)
this.store.save()
},
scope: this
}],
... cutted out ...
在保存存储之前,我可以在控制台中看到修改后的数据。并且该数据没有传递到服务器 为JsonWriter设置“encode:false”。测试创建和销毁。
我在那里找到了它:为JsonWriter设置“encode:false”。测试创建和销毁。
我在那里找到了:我猜它没有记录任何原因造成的变化。将侦听器添加到
save
事件中,查看store.getModifiedRecords()
在编辑后为您提供了什么?store.getModifiedRecords()可以。我可以在控制台中看到修改过的对象(行)列表。我猜它没有记录任何原因的更改。将侦听器添加到save
事件中,查看store.getModifiedRecords()
在编辑后为您提供了什么?store.getModifiedRecords()可以。我可以在控制台中看到已修改对象(行)的列表。