【问题标题】:Send all records of a Extjs store to server at once一次将 Extjs 存储的所有记录发送到服务器
【发布时间】:2013-04-12 03:35:45
【问题描述】:

如何在一个 POST 调用中将我的整个商店数据发送到服务器? 可以是json格式。

谢谢。

更新:

这是我的商店代码:

Ext.define('App.store.consultorio.Receita', {
    extend: 'Ext.data.Store',
    model: 'App.model.consultorio.Receita',
    autoLoad: false,
    proxy: {

        type: 'rest',
        reader: {
            type: 'json'
        },
        writer: {
            type: 'json'
        },
        url: 'consultas/receita.json'
    }
});

【问题讨论】:

    标签: extjs extjs4


    【解决方案1】:

    您可以将存储中的每条记录设置为脏,然后调用 sync()

    store.each(function(record){
        record.setDirty();
    });
    
    store.sync();
    

    此外,您的商店正在使用 RESTful 代理,默认情况下不会批处理操作。见http://docs.sencha.com/ext-js/4-2/#!/api/Ext.data.proxy.Rest-cfg-batchActions

    您的商店应如下所示:

    Ext.define('App.store.consultorio.Receita', {
        extend: 'Ext.data.Store',
        model: 'App.model.consultorio.Receita',
        autoLoad: false,
        proxy: {
    
            type: 'rest',
            batchActions: true, //<------
            reader: {
                type: 'json'
            },
            writer: {
                type: 'json'
            },
            url: 'consultas/receita.json'
        }
    });
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-19
    • 2014-08-20
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    • 2021-11-29
    相关资源
    最近更新 更多