2012-04-26 101 views
0

記錄值我有以下代碼覆蓋ExtJS的

var record = form.getRecord(); 
    var values = form.getValues(); 
    record.set(values); 
    // record.data.DeliveryFrom = "test1"; 
    record.set('DeliveryFrom', 'test2'); 
    record.save(); 

我想重寫屬性DeliveryFrom後,我從我的形式獲取值。但是,當我查看螢火蟲DeliveryFrom中的結果爲空。你會看到上面我嘗試了2種不同的方式來設置這個值。

我使用ExtJS的4.1

+0

看看這個.. 。http://stackoverflow.com/questions/11762050/ext-js-4-convert-json-object-to-another-json-object-using-javascript – MacGyver 2012-08-27 23:17:11

回答

1

應該工作(假設構成其Ext.form.Basic)如果不是(如果它Ext.form.Panel),然後用form.getForm()

var record = form.getRecord(); 
form.updateRecord(record); //We use update record, its almost the same as you were using but in just one call 
record.beginEdit(); //Put the record in edit mode 
record.set('DeliveryFrom', 'test2'); 
record.endEdit(); //End editing the record and commit changes 
record.save(); //Commit changes to backend