0

我有这么简单的问题,但找不到答案(文档)。我创建了 Grid ,从MySQL数据库中检索信息。使用分机 JS 4.2。让我们看一下脚本...

Ext.define("AppStore",{
    extend: "Ext.data.Model",
    fields: [
        {name: "nickname" , type: "auto"},
        {name: "email"    , type: "auto"}
    ]
});

var store = Ext.create("Ext.data.Store",{
    model: "AppStore",
    proxy: {
        type: "ajax",
        api: {
            read    : "./read.php",
            update  : "./update.php"
        },
        reader: {
            type: "json",
            root: ""
        },
        writer: {
            type: "json",
            writeAllFields: true,
            encode: false,
            root: ""
        }
    },
    listeners: {
        read: function(operation, callback, scope){

        },
        update: function(operation, callback, scope){
            // Do I have to do something from here ?
        }
    },
    autoLoad: true
});

Ext.create("Ext.grid.Panel",{
    store: store,
    selMode: "cellmodel",
    columns: [
        {
            text: "Nickname",
            flex: 1,
            dataIndex: "nickname",
            editor: {
                xtype: "textfield",
                allowBlank: false
            }
        },
        {
            text: "Email",
            flex: 1.5,
            dataIndex: "email",
            editor: {
                xtype: "textfield",
                allowBlank: false
            }
        }
    ],
    plugins: [
        Ext.create("Ext.grid.plugin.CellEditing",{
            clicksToEdit: 2
        })
    ]
});

一切正常,只是对在 Grid 单元格中更改数据后如何向MySQL发送请求以更新数据感兴趣。任何示例、文档或如何完成此任务的方式将不胜感激,谢谢...

4

1 回答 1

1

通常,您需要在网格存储上调用sync()以便将模型更改持久保存到服务器。这可以配置为在每次编辑时自动发生(请参阅商店的autoSync 属性)。但是,我建议最好根据某些特定操作(例如,单击“保存”按钮等)来处理 sync() 调用。

于 2013-05-27T19:21:34.820 回答