架构师将存储同步到WebService

Architect sync Store to WebService

本文关键字:同步 WebService 存储      更新时间:2024-02-09

我想将在表单的某些字段中编辑过的设置同步到服务器。

Firebug显示:点击按钮,没有任何连接
JavaScript控制台显示:无错误。

我所拥有的:

onButtonClick: function(button, e, eOpts) {
    Ext.getStore("optionsStore").getAt(0).setDirty();
    Ext.getStore("optionsStore").commitChanges();
    Ext.getStore("optionsStore").sync();
}

我用来加载:

onJsonstoreLoad: function(store, records, successful, eOpts) {
    Ext.getCmp("optionsForm").getForm().loadRecord(store.getAt(0));
}

我的商店是由建筑师建造的:

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        autoLoad: true,
        model: 'optionsModel',
        storeId: 'optionsStore',
        proxy: {
            type: 'ajax',
            api: 'read: ''http://localhost:52699/api/AdminPanel?do=select'','r'ncreate: ''http://localhost:52699/api/AdminPanel?do=insert'','r'nupdate: ''http://localhost:52699/api/AdminPanel?do=update'','r'ndestroy: ''http://localhost:52699/api/AdminPanel?do=delete''',
            url: 'allSettings.json',
            reader: {
                type: 'json',
                root: 'globalSettings'
            },
            writer: {
                type: 'json',
                allowSingle: false,
                encode: true,
                root: 'globalSettings'
            }
        },
        listeners: {
            load: {
                fn: me.onJsonstoreLoad,
                scope: me
            }
        }
    }, cfg)]);
},

这很简单:

onButtonClick: function(button, e, eOpts) {
    Ext.getCmp("optionsForm").getForm().updateRecord(Ext.getStore("optionsStore").getAt(0));
    Ext.getStore("optionsStore").getAt(0).setDirty();
    Ext.getStore("optionsStore").commitChanges();
    Ext.getStore("optionsStore").sync();
}