Php 使用ExtStore编写器更新数据库-ExtJS 4.2

Php 使用ExtStore编写器更新数据库-ExtJS 4.2,php,database,extjs,writer,Php,Database,Extjs,Writer,我已经修改了sencha的编剧,但我无法更新数据库中的数据。我有一个php脚本,可以在服务器端实现这一点,但我看不到extjs的更新调用。我正在使用读卡器获取数据,它工作正常,但当我尝试更新发送到服务器的数据时,我从未接到呼叫 这是我的密码: Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.state.*', 'Ext.form.*' ]); Ext.onReady(functio

我已经修改了sencha的编剧,但我无法更新数据库中的数据。我有一个php脚本,可以在服务器端实现这一点,但我看不到extjs的更新调用。我正在使用读卡器获取数据,它工作正常,但当我尝试更新发送到服务器的数据时,我从未接到呼叫

这是我的密码:

Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.state.*',
    'Ext.form.*'
]);

Ext.onReady(function(){
    // Define our data model
    Ext.define('Empresa', {
        extend: 'Ext.data.Model',
        fields: [
            {
                name: 'Id',
                type: 'int'
            },
            {
                name: 'Nombre',
                type: 'string'
            },
            {
                name: 'Estado',
                type: 'int'
            },
            {
                dateFormat: 'd/m/Y',
                name: 'FechaCreacion',
                type: 'string'
            }
        ]
});


    // create the Data Store
    var store = Ext.create('Ext.data.Store', {
        // destroy the store if the grid is destroyed
        autoDestroy: true,
        model: 'Empresa',
        //autoLoad: true,
        proxy: {
            type: 'jsonp',
            api: {
                read: 'http://fplweb2.localhost/empresa/listar/',
                write: 'http://fplweb2.localhost/empresa/grabar/',
                update: 'http://fplweb2.localhost/empresa/grabar/',
                destroy: 'http://fplweb2.localhost/empresa/eliminar/',
            },
            reader: {
                type: 'json',
                root: 'listaempresas'
                },
                writer: {
                    type: 'json'
                }
        },
        sorters: [{
            property: 'start',
            direction: 'ASC'
        }]
    });

    store.load();

    var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
        clicksToMoveEditor: 1,
        autoCancel: false
    });

    // create the grid and specify what field you want
    // to use for the editor at each column.
    var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        columns: [
            {
                xtype: 'gridcolumn',
                dataIndex: 'Id',
                text: 'Id',
                editor: 'numberfield'
            },
            {
                xtype: 'gridcolumn',
                dataIndex: 'Nombre',
                text: 'Nombre',
                editor: 'textfield'
            },
            {
                xtype: 'gridcolumn',
                dataIndex: 'Estado',
                text: 'Estado',
                editor: 'numberfield'
            },
            {
                xtype: 'gridcolumn',
                dataIndex: 'FechaCreacion',
                text: 'FechaCreacion',
                editor: 'datefield'
            }
        ],
        renderTo: Ext.getBody(),
        height: 600,
        title: 'Lista de Empresas',
        tbar: [{
            text: 'Agregar Empresa',
            handler : function() {
                rowEditing.cancelEdit();

                // Create a model instance
                var r = Ext.create('Empresa', {
                    Id: store.getCount() + 1,
                    Nombre: 'Nueva Empresa',
                    Estado: '1',
                    FechaCreacion: Ext.Date.clearTime(new Date())
                });

                store.insert(0, r);
                rowEditing.startEdit(0, 0);
                console.log('Antes de' + store.getCount());
                //store.sync();
                console.log('Despues de: ' + store.getCount());
            }
        }, {
            itemId: 'removeEmpresa',
            text: 'Eliminar Empresa',
            handler: function() {
                var sm = grid.getSelectionModel();
                rowEditing.cancelEdit();
                store.remove(sm.getSelection());
                if (store.getCount() > 0) {
                    sm.select(0);
                }
            },
            disabled: true
        }],
        plugins: [rowEditing],
        listeners: {
            'selectionchange': function(view, records) {
                grid.down('#removeEmpresa').setDisabled(!records.length);
            }
        }
    });
});
这就是我的服务器端脚本返回给读者的内容:

{"listaempresas":[{"Id":"1","Nombre":"DyS Nevados SRL","Estado":"1","FechaCreacion":"2013-05-13 10:40:00"}]}

我在一些帖子中读到我需要做一个
store.sync()
,但我得到了一个错误。我使用的是
extj4.2
。所以往里看,这种方法并不存在。我做错了什么?

启用商店的
autoSync

var store = Ext.create('Ext.data.Store', {
    autoSync : true
    // ...
}

默认值为
false
。现在,存储将在每次编辑后自动同步。

如果您希望有条件地执行同步(如值未更改时阻止同步等),请选择该选项或将事件处理程序绑定到“编辑”事件亲爱的dougajmcdonald。。。你能给我一个例子,我必须如何在现实世界中的应用程序?我会很感激的。。。非常感谢。亲爱的Darin Kolev。。。在服务器中更新数据的最佳方式是什么。。。这是最好的方式吗?你能给我举个更好的例子吗?谢谢…我得到了这个错误:TypeError:q是未定义的…aw.height],“L”,v,aw.y+aw.height],“L”,v,t]];如果(!ap.fillPath){ap.fillPath=z.add。。。