2012-07-23 76 views
1

爲什麼一個記錄會成功地用一個剩餘代理調用POST/Create動作,然後在後續保存時成功保持,調用相同的POST/Create方法而不是PUT /更新一個?EXTJS 4模型試圖創建一個持久化記錄(而不是更新)

帖子

var ref = beginQuestionnaireControl.getPegfileRef(); 
var Pegfile = Ext.create('Pegfect.model.Pegfile', { 
    Id: 0, 
    Reference: ref 
}); 
Pegfile.save({ 
    scope: this, 
    success: function (pegfile, operation) { 
    this.activePegfile = pegfile; 
    this.startQuestions(); 
    }, 
    failure: function() { 
    alert('That ref is not unique'); 
    } 
}); 

也帖子(期待一個PUT)

this.activePegfile.save({ 
     success: function() { 
     successCallback(); 
     }, 
     failure: function() { 
     alert('oops, error saving Pegfile'); 
     } 
    }); 

代理

proxy: 
    { 
    type: 'rest', 
    url: 'Pegfile', 
    timeout: 120000, 
    noCache: false, 

    reader: 
    { 
     type: 'json', 
     root: 'data', 
     successProperty: 'success' 
    }, 

    writer: 
    { 
     type: 'json', 
     writeAllFields: true 
    } 
    } 

回答

0

訣竅是定義一個N於模型「Id」屬性:

idProperty: 'Id' 

迫切需要在這一個部分約定優於配置...

+1

默認爲「ID」,但區分大小寫 – 2012-07-23 20:06:33

相關問題