updateRecord():需要一条记录

时间:2019-05-24 10:18:10

标签: extjs crud

onSaveClick: function(button) {
    var dialog, store, record;
    dialog = button.up('window').down('form');
    // var temprec = dialog.getRecord();
    dialog.updateRecord();
    // dialog.addSorted();
    record = dialog.getRecord();
    store = record.store;
    if (store) {
        if (record.phantom) {
            store.add(record);
        }
        console.log(dialog);
        store.sync({
            failure: function(batch) {
                store.rejectChanges();
                Application.app.showError(batch.exceptions[0].getError().response);
            }
        });
    } else {
        record.save();
    }
    this.closeView();
}

我正在尝试在extJs中执行CRUD操作,但在updateRecord()中却遇到了一些错误:

  

需要记录。

  dialog.getRecord();
//        dialog.updateRecord();
          dialog.updateRecord(); 
//        record = dialog.getRecord();
          record = dialog.getValues();
//        dialog.updateRecord();     
          store = record.store;    

i tried getRecord and getValues both working properly but getting same error on updateRecord();
ext-all-debug.js:2612 Uncaught Error: A record is required.

1 个答案:

答案 0 :(得分:0)

要根据文档(https://docs.sencha.com/extjs/6.7.0/classic/Ext.form.Panel.html#method-updateRecord)使用updateRecord(),您需要在表单面板中use loadRecord(record)

如果没有一条记录已加载,或者如果只在使用方法getValues()之前加载记录,则我想使用方法updateRecord()