extjs4为什么api属性不能在Store中运行

时间:2014-01-30 10:43:26

标签: extjs4.1

我正在尝试在商店中获取ajax代理的测试api属性,但似乎它不起作用。 我不知道为什么它不起作用。我刚刚参考了参考书。 有人请给我一个建议吗?我附上了源代码。

以下是模型的源代码。

Ext.define('directModel', {
extend : 'Ext.data.Model',
fields : [
    {name : 'id',               type : 'int'},
    {name : 'firstName',        type : 'string'},
    {name : 'lastName',         type : 'string'},
    {name : 'company',          type : 'string'},
    {name : 'email',                type : 'string'},
    {name : 'dob',                  type : 'date'},
    {name : 'age',                  type : 'int'},
    {name : 'coworker',         type : 'string'}
    ]
});

以下是商店的源代码。

var store = Ext.create('Ext.data.Store', {
    storeId : 'directStore',
    model : 'directModel',
    proxy : {
        type : 'ajax',          
        api : {
            read : '/common/command.jsp?action=read',
            create : '/common/command.jsp?action=add',
            update : '/common/command.jsp?action=update',                   
            destory : '/common/command.jsp?action=remove'
        },
        reader : {
            type : 'json',
            root : 'root'
        },
        writer : {
            type : 'json',
            root : 'data'
        }
    }
});

var s = Ext.data.StoreManager.get('directStore');   
s.load({
    callback : function(){

        var r = Ext.ModelManager.create({
            id : '346012',
            firstName : '',
            lastName : '',
            company : '',
            email : '',
            dob : '',
            age : 3,
            coworker : 'N/A'
        }, 'directModel');

        s.add(r);
        s.sync();

    }
});

我刚装载商店从服务器端带来数据,我发现它没关系。 我还尝试添加新的reocrd并调用“sync”功能。 据我所知,请求url应该是api的create属性。然而什么也没发生。

请给我一个建议。

0 个答案:

没有答案