朱在铸先生 2017-02-06 02:36 采纳率: 100%
浏览 1501
已采纳

extjs4 问题,store.load问题

 businessQueryModule.orgInfoStore = new Ext.data.Store({
    proxy : {
        type : 'ajax',
        url : businessQueryModule.queryUtil + '!queryOrgInfo',
        reader : {
            type : 'json',
            root : "enumerationList"
        }
    },
    fields : [ {
        name : 'enumMeaning'
    }, {
        name : 'enumCode'
    } ]
});
 xtype : "combo",
    readOnly : false,
    editable : false,
    mode : 'local',
    emptyText : '请选择城市',
    valueField : 'enumCode',
    displayField : 'enumMeaning',
    triggerAction : 'all',
    listeners : {
        render : function() {
            Ext.fly(this.el).on('click',function(e,t) {
                    businessQueryModule.orgInfoStore.load({
                            params : {
                                'domainId' : Ext.getCmp(businessQueryModule.idPrefix+ 'domainId').getValue()
                            }
                    });
            });
        },
        'change' : function(obj,newValue, oldValue,eOpts) {
            Ext.getCmp(businessQueryModule.idPrefix + 'equipMentID').clearValue();
            Ext.getCmp(businessQueryModule.idPrefix + 'termID').clearValue();
            Ext.getCmp(businessQueryModule.idPrefix + 'operatorNum').clearValue();
            if(newValue == ""){
                Ext.getCmp(businessQueryModule.idPrefix + 'orgID').clearValue();
            }

        }
    },
    store : businessQueryModule.orgInfoStore,
    margin : '5 0 0 0',
    id : businessQueryModule.idPrefix
            + 'orgID',
    width : 150
}

当点击下拉框后,会先store.load一次,再在监听里面store.load一次。
共load了两次,而且第一次load应为没有传参,后台还会报错。
怎么解决这个问题,我只想在监听里面load就可以了,因为如果params写在外面会取不到对象的值。

  • 写回答

2条回答 默认 最新

  • 朱在铸先生 2017-02-06 07:57
    关注

    将 proxy 写在事件里面就可以了,用store.setProxy()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • Go 旅城通票 2017-02-06 03:09
    关注
      businessQueryModule.orgInfoStore = new Ext.data.Store({
     autoLoad :false,//////////////////////////////
        proxy : {
            type : 'ajax',
            url : businessQueryModule.queryUtil + '!queryOrgInfo',
            reader : {
                type : 'json',
                root : "enumerationList"
            }
        },
        fields : [ {
            name : 'enumMeaning'
        }, {
            name : 'enumCode'
        } ]
    });
    
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求制作一个个人网页,
  • ¥15 寻涂色内存脚本作者有项目有市场有资源.却技术
  • ¥15 蓝桥杯c51单片机问题
  • ¥15 ajax跨域问题请求修改代码
  • ¥15 python matplotlib
  • ¥15 短信测压+语音,有偿,必须用Python
  • ¥20 COCOS2DX的protobuf协议注册函数问题
  • ¥15 (标签-Pytorch|关键词-Stream)
  • ¥15 求深圳2019年开放数据应用创新大赛的营运车辆数据!
  • ¥15 软件UI界面绘制折线图