繁体   English   中英

如何保存ExtJS 5 AjaxProxy?

[英]How do I get ExtJS 5 AjaxProxy to save?

我正在将应用程序升级到ExtJS 5,但似乎无法使用RowEditing将已编辑的记录回发到我的服务器上。

Ext.define("MyRecordDef", { extend: "Ext.data.Model" });

var MyEditor = Ext.create('Ext.grid.plugin.RowEditing', { clicksToEdit: 1 });

var MyStore = new Ext.data.Store({
        model:      "MyRecordDef",
        autoSync:   true,
        proxy: {
            type:           "ajax",
            url:            "ajaxurl.aspx",
            batchActions:   false,
            extraParams:    { Command: 'Save' },
            reader:         { type: "json", rootProperty: "rows" },
            writer:         { type: "json", encode: true, writeAllFields: true }
        }
    });

var MyGrid = new Ext.grid.GridPanel({
    store:      MyStore,
    plugins:    [ MyEditor ],
    columns:        [
        {
        id:             "fieldtoedit",
        dataIndex:      "fieldtoedit",
        editor:         new Ext.form.NumberField()
        }
    ]
});

行编辑器出现,我可以更改值并单击“更新”按钮,但是什么也没发生 没有请求,控制台中没有记录错误。

我添加了以下内容:

MyGrid.on('edit', function (e) {
    alert('You are Editing ' + e.context.record.id);
    MyStore.sync();  // attempt to force a sync
});

我收到具有正确记录号的警报,但仍然没有AJAX请求。 就像ExtJS 完全忽略了作者。

对于每个CRUD操作,我没有不同的端点,因此我没有使用api config选项,它应该使用url

首先,在使用encode: true时,必须在writer上定义rootProperty 然后,将fields添加到MyRecordDef后,将MyRecordDef请求。

工作示例: http : //jsfiddle.net/jjVwR/3/ (保存无效,但是您可以在控制台上看到请求已发送)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM