Extjs4 重命名并插入erro TreeStore ExtJS 4.1.1
各位晚上好 当我更新方法时,它不会保存所有模型项,如“tipoNo”和“pai”。有人知道我能做什么吗 请求有效负载Extjs4 重命名并插入erro TreeStore ExtJS 4.1.1,extjs4,rename,extjs4.1,treepanel,Extjs4,Rename,Extjs4.1,Treepanel,各位晚上好 当我更新方法时,它不会保存所有模型项,如“tipoNo”和“pai”。有人知道我能做什么吗 请求有效负载 /** * Rename * * @param {Ext.grid.plugin.CellEditing} editor * @param {Object} e */ updateList : function (editor, e) { var node = e.record; node.sav
/**
* Rename
*
* @param {Ext.grid.plugin.CellEditing} editor
* @param {Object} e
*/
updateList : function (editor, e) {
var node = e.record;
node.save({
success: function(list, operation) {
console.log("updated");
},
failure: function(list, operation) {
var error = operation.getError(),
msg = Ext.isObject(error) ? error.status + ' ' + error.statusText : error;
Ext.MessageBox.show({
title: 'Notificação',
msg: msg,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
}
});
},
这是请求中发送的信息
{"parentId":1,"nome":"qwfqwfqw"}
型号:
“我的模型”中的字段
fields : [ {
name : 'id',
type : 'long'
},{
name : 'pai',
type : 'long'
}, {
name : 'nome',
type : 'string'
}, {
name : 'tipoNo',
type : 'string'
}, {
name : 'leaf',
type : 'boolean',
convert : function(value, record) {
var no = record.get('tipoNo');
return (no == "CLIENTE" ? true : false);
}
} ],
代理
代理服务器上的必要信息
proxy : {
type : 'rest',
url : Webapp.link('node'),
reader : {
type : 'json',
root : 'nodes',
idProperty : 'id'
},
writer : {
type : 'json',
writeAllFields : false
}
}
控制器方法
/**
* Rename
*
* @param {Ext.grid.plugin.CellEditing} editor
* @param {Object} e
*/
updateList : function (editor, e) {
var node = e.record;
node.save({
success: function(list, operation) {
console.log("updated");
},
failure: function(list, operation) {
var error = operation.getError(),
msg = Ext.isObject(error) ? error.status + ' ' + error.statusText : error;
Ext.MessageBox.show({
title: 'Notificação',
msg: msg,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
}
});
},
看看您的代理配置。JSON编写器的
writealFields
属性设置为false。从文件中:
True to write all fields from the record to the server.
If set to false it will only send the fields that were modified.
因此,任何未触及的字段都不会发送回服务器。如果要将所有属性发送到服务器,请将writealFields
设置为true(或仅删除它,因为true是默认值),然后重试。这种情况下的解决方案:
/**
* Executa a edição
*
* @param {Ext.grid.plugin.CellEditing} editor
* @param {Object} e
*/
updateList : function (editor, e) {
var node = e.record;
var me = this;
var nodeTree = me.getNodeTree();
var method = (node.data.id !== undefined ? 'PUT' : 'POST');
var post = {
id: (node.data.id !== undefined ? null : node.data.id),
nome: node.data.nome,
pai: (node.data.parentId == -1 ? null : node.data.pai),
tipoNo: node.data.tipoNo
};
Ext.Ajax.request({
url: Webapp.link("node"),
headers: { 'Content-Type': 'application/json' },
jsonData: post,
method: method,
success: function(response){
var text = response.responseText;
console.log(text);
nodeTree.refreshView();
}
});
},
我尝试过这样做,但是当我发送信息时,我遇到了序列化问题。