gpt4 book ai didi

javascript - ExtJS。网格更新后 Ext.data.DirectStore 向服务器发送空数据

转载 作者:行者123 更新时间:2023-11-28 02:48:14 24 4
gpt4 key购买 nike

我在将数据从 Ext.data.DirectStore 保存到服务器时遇到问题

这是我的代码:

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}

为什么data为空,我对网格的更改在哪里?我做错了什么或者这是一个错误

更新:

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”。经过创建和销毁测试。我在那里找到了它:http://www.sencha.com/forum/showthread.php?80958-DirectStore-and-write-function

关于javascript - ExtJS。网格更新后 Ext.data.DirectStore 向服务器发送空数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4410028/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com