如何在ext js4中动态更改代理api?

时间:2013-01-21 10:20:14

标签: api extjs proxy extjs4

我正在使用MVC结构在extjs4中工作,我想将我的代理设置api (创建)更改为另一个url。我在这一点上陷入困​​境。这是我的一些代码

 Ext.define('Balaee.model.sn.UserModel',{
        extend: 'Ext.data.Model',
        //idproperty:'userId',//fields property first position pk. 
        fields: ['userId','firstName','middleName','lastName','languageId','primaryEmail','birthDate','password','securityQuestionId','securityQuestionAnswer','isMale','creationTime','ipAddress','confirmationCode','userStatusId',],
        proxy:
        {
            type:'ajax',
            api:
            {
                read:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin',
                create:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin',
                update:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/Registration'

            },//end of api
            reader:
            {
                type:'json',
            },//end of reader
            writer:
            {
                type:'json',
                root:'records',
            },//End of writer
        }//end of proxy
}

请给我一些建议。

1 个答案:

答案 0 :(得分:3)

您可以使用Ext.applyExt.applyIf执行此类操作。

var userModel = Ext.create('Balaee.model.sn.UserModel',{}),
    proxy = userModel.getProxy();

Ext.apply(proxy.api, {
    create  : '/controller/new',
    read    : '/controller/load',
    update  : '/controller/update',
    destroy : '/controller/destroy_action'
});