2016-04-11 66 views
0

我试图使组合加载项目(数据存储)与AutoLoad:true,但是,我不知道我是否这样做是正确的。我是一个小新手Extjs,所以,不要粗鲁,请嘿嘿Combobox忽略autoLoad [Extjs]

这里的代码!

items: [{ 
       xtype: 'form', 
       padding: 20, 
       name: 'formReplyParameters', 
       layout: 'anchor', 
       fieldDefaults: { 
        msgTarget: 'under', 
        labelAlign: 'top' 
       }, 
       defaults: { 
        padding: 10 
       }, 
       items: [{ 
        xtype: 'checkboxfield', 
        name: 'interactive', 
        inputValue: true, 
        fieldLabel: 'Interactive', 
        anchor: '100%' 
       }, { 
        xtype: 'textfield', 
        name: 'timeResponse', 
        fieldLabel: 'Time response', 
        anchor: '100%' 
       }, { 
        xtype: 'combobox', 
        fieldLabel: 'Alert channel', 
        name: 'uuidResponseParameterType', 
        queryMode: 'local', 
        store: new Ext.data.Store({ 
         fields: [{ 
          name: 'description', 
          type: 'string' 
         }, { 
          name: 'name', 
          type: 'string' 
         }, { 
          name: 'uuid', 
          type: 'string' 
         }], 
         autoLoad: true, 
         hideTrigger: true, 
         minChars: 1, 
         triggerAction: 'query', 
         typeAhead: true, 
         proxy: { 
          type: 'ajax', 
          url: "../blabla", 
          actionMethods: { 
           create: "POST", 
           read: "POST", 
           update: "POST", 
           destroy: "POST" 
          }, 
          extraParams: { 
           action: "catalog", 
           catalog: "parametersType", 
           params: JSON.stringify({ 
            uuidToken: Ext.connectionToken 
           }) 
          }, 
          reader: { 
           type: 'json', 
           root: 'List' 
          }, 
          listeners: { 
           exception: function(proxy, response, operation, eOpts) { 
            var responseArray = JSON.parse(response.responseText); 
            Ext.Notify.msg(responseArray.message, { 
             layout: "bottomright", 
             delay: 5000, 
             type: "error" 
            }); 
           } 
          } 
         } 
        }), 
        anchor: '100%', 
        typeAhead: true, 
        triggerAction: 'all', 
        valueField: 'uuid', 
        displayField: 'description', 
        allowBlank: false, 
        listeners: { 
         change: function (combo, value) { 
          var type = combo.valueModels[0].data.name; 
          var channel = me.down('[name="uuidChanel"]'); 
          channel.clearValue(); 
          var channelStore = new Ext.data.Store({ 
           fields: [{ 
            name: 'description', 
            type: 'string' 
           }, { 
            name: 'name', 
            type: 'string' 
           }, { 
            name: 'uuid', 
            type: 'string' 
           }], 
           autoLoad: true, 
           hideTrigger: true, 
           minChars: 1, 
           triggerAction: 'query', 
           typeAhead: true, 
           proxy: { 
            type: 'ajax', 
            url: "../handler/custom/customEvent.ashx", 
            extraParams: { 
             action: "catalog", 
             catalog: type, 
             params: JSON.stringify({ 
              uuidToken: Ext.connectionToken 
             }) 
            }, 
            reader: { 
             type: 'json', 
             root: 'list' 
            }, 
            listeners: { 
             exception: function(proxy, response, operation, eOpts) { 
              var responseArray = JSON.parse(response.responseText); 
              Ext.Notify.msg(responseArray.message, { 
               layout: "bottomright", 
               delay: 5000, 
               type: "error" 
              }); 
             } 
            } 
           } 
          }); 
          channelStore.load(); 
          channel.bindStore(channelStore); 
         } 
        } 
       }, { 
        xtype: 'combo', 
        name: 'uuidChanel', 
        fieldLabel: 'Channel', 
        valueField: 'uuid', 
        displayField: 'description', 
        anchor: '100%', 
        store: null, 
        allowBlank: false 
       }] 
      }] 

的问题是在组合:uuidChannel 如果有人能帮助,非常感谢!

+0

与'name:'uuidChanel''组合配置为'store:null' ... –

+0

@SergeyNovikov相信我,我尝试了几次而没有'store:null',没有任何反应。 – Diego

+0

啊,对不起,没有仔细检查整个代码。 –

回答

0

为什么你确实认为autoLoad: true能起作用?因为当你尝试打开最后一个组合框时,它仍然在加载?

我觉得你的问题是,新的存储中创建每次连击name: 'uuidResponseParameterType'change事件触发和存储autoLoad: true意味着

商店的负载方法创建后自动调用

你必须创建商店只需一次,然后在组合change事件中加载(或本地过滤)新的extraParams

+0

Woops,我真的不明白你是什么意思,呵呵,但是,我修好了! – Diego

0

的事情是,(笨)

channel.clearValue();

此字段正在解决所有问题。这种“clearValue”在那里,因为我相信,删去“的uuid”的数据,它返回我的新数据和“绑定”至底部

channelStore.load(); 
channel.bindStore(channelStore); <<< 

所以,我觉得,我把新的数据,但是这个“明确的价值”,只是在用我绑定的“绑定”来擦除数据。所以,我只是消除channel.clearValue();,这就解决了问题! :)

+0

现在我完全混淆了你实际上在“组合框忽略autoLoad”的意思,因为在你的代码示例中'clearValue()'与store'autoLoad'没有任何关系......你能否更新你的问题,以便它反映你的实际问题?稍后我会更新我的答案,以向您展示您的代码存在的实际问题。 –

+0

@SergeyNovikov,首先,对不起朋友,回答你太晚了。让我来解释一下,我有2个'combobox',第二个没有数据,但是第一个数据有数据,所以我有一个'change'函数将第一个组合的数据更改为第二个,'autoLoad:true',应该将第一个'combo'传递给第二个的数据加载到第二个,但是像我之前说过的那样,'clearValue();'已经擦除了我的数据(数据当第一个'combo'传递给第二个时)。我不知道你是否明白,但就是这样! – Diego