簡體   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