【问题标题】:ExtJS 4 JSON not updating/writingExtJS 4 JSON 不更新/写入
【发布时间】:2013-06-11 16:59:10
【问题描述】:

我正在学习 ExtJS 4,我正在尝试将更新的结果从网格写入 json 文件,我可以读取这些值,但是当我尝试更新它们时,没有任何更新。我在 Mint 上运行 Apache,我还将 htdocs 文件夹和里面的所有内容设置为 chmod 777,以防权限弄乱了我的 json 写作。那里没有运气:(

这是我的代码: 型号:

Ext.define('APP.model.RiverModel', {
extend : 'Ext.data.Model',

    autoSync : true,

fields : [
{
    name : 'id',
    type : 'int',
},
{
    name : 'river',
    type : 'string',
},
{
    name : 'len',
    type : 'int',
}
],
proxy: {
    type: 'ajax',
    api: {
        read: 'app/data/Lengths.json',
        create: 'app/data/updateLengths.json',
        destroy: 'app/data/updateLengths.json',
        update: 'app/data/updateLengths.json'
    },
    actionMethods: {
            create : 'POST',
            read   : 'POST',
            update : 'POST',
            destroy: 'POST'
    },
    reader: {
        type: 'json',
        root: 'rivers',
        successProperty: 'success'
    },
    writer:
    {
        type: 'json',
        root: 'rivers',
        writeAllFields : false,  
        allowSingle :false
    },
},

});

商店:

Ext.define('APP.store.LevelDb', {
extend : 'Ext.data.Store',
autoLoad : true,
autoSync : true,
model : 'APP.model.RiverModel',

}); console.log('存储加载');

控制器更新功能:

lineSave: function(button) {
    var win = button.up('window'),
        form = win.down('form'),
        record = form.getRecord(),
        values = form.getValues();
        values.len = parseInt(values.len);
        //values.len = 555;
        console.log(values);
        record.set(values);
        win.close();
        this.getLevelDbStore().sync();
},

干杯:)

【问题讨论】:

    标签: javascript json apache extjs extjs-mvc


    【解决方案1】:

    如果您尝试通过 ExtJS(例如 JavaScript)更新实际的 .json 文件,您将不会有任何运气。如果您需要更新文件,则需要使用一些可以访问您要更新的文件的服务器端技术来完成。

    【讨论】:

    • 谢谢 :) 我通过 PHP 传递了 JSON 并使用了 file_put_contents() :P
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多