2012-09-08 38 views
0

晚上好球員,重命名並插入埃羅TreeStore ExtJS的4.1.1

當我更新它不保存所有的模型的項目,如「tipoNo」和「拍」的方法。有人知道我能做什麼?

請求負載

這是在請求發送的信息。

{"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 
      }); 
     } 
    }); 
}, 

回答

0

解決方案在這種情況下:

/** 
* 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(); 
     } 
    }); 

}, 
0

看看你的代理服務器配置。您的JSON編寫器將writeAllFields屬性設置爲false。從Ext.data.writer.Json文檔:

True to write all fields from the record to the server. 
If set to false it will only send the fields that were modified. 

所以沒有被觸及任何字段將不會被髮送回服務器。如果要將所有屬性發送到服務器,請將writeAllFields設置爲true(或僅將其刪除,因爲true是默認值),然後重試。

+0

我試着這樣做,但是當我發信息,我有序列化的問題。 –