Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何保存ExtJS 5 AjaxProxy?_Javascript_Ajax_Extjs_Extjs5_Roweditor - Fatal编程技术网

Javascript 如何保存ExtJS 5 AjaxProxy?

Javascript 如何保存ExtJS 5 AjaxProxy?,javascript,ajax,extjs,extjs5,roweditor,Javascript,Ajax,Extjs,Extjs5,Roweditor,我正在将一个应用程序升级到ExtJS 5,而我似乎无法使用行编辑将编辑过的记录发布回我的服务器 Ext.define("MyRecordDef", { extend: "Ext.data.Model" }); var MyEditor = Ext.create('Ext.grid.plugin.RowEditing', { clicksToEdit: 1 }); var MyStore = new Ext.data.Store({ model: "MyRecordD

我正在将一个应用程序升级到ExtJS 5,而我似乎无法使用行编辑将编辑过的记录发布回我的服务器

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
。 然后在将
字段添加到
MyRecordDef
后,发送请求


工作示例:(保存不起作用,但您可以在控制台上看到请求已发送)

您的记录是否定义了任何字段?它不。。。在v5中不再需要定义字段(前提是不需要重写数据类型等)。但是IIRC,我今天确实有一个早期版本的代码(更接近我一直使用的v4代码),它保留了旧的字段,并具有相同的结果。祝福你。1000倍。工作完美。我完全忽略了writer需要rootProperty,文档中也没有关于writer需要字段定义的内容(因为它们不适合读者)。