Dynamic store not loading data in combo box extjs

Core7s

I have two combo boxes say combo 1 and combo 2 that get populated with two different stores (say store 1 and store 2). The value in combo2 depends on what is selected in combo 1. I then query the server to get the array for combo2. In other words, my selection in combo1 determines the values for combo2. The code I have set up is not working and gives me a very generic error Error: Object doesn't support this action. I see the return values in the browser debugger so I know its not my ajax request. I think I am missing something small in the combo box that keeps the values from displaying. Please see the code below to get a better idea

   var store1 = Ext.create('Ext.data.ArrayStore', {
  model: 'store1model',
  autoLoad: true,
  autoDestroy: true,
  proxy: {
    type: 'ajax',
    url: 'backend.java'
    extraParams: {
      'param1': param1
    },
    reader: {
      type: 'json'
    }
  }
});

var store2 = Ext.create('Ext.data.ArrayStore', {
  model: 'store2model',
  autoLoad: true,
  autoDestroy: true,
  storeId: 'store2Id',
  proxy: 'memory',
  readre: {
    type: 'json'
  }
});

var panel = Ext.create('Ext.form.Panel', {
  title: 'Panel',
  id: 'PanelId',
  url: 'backened.java',
  method: 'GET',
  items: [{
    xtype: container,
    layout: 'column',
    items: [{
      xtype: 'container',
      columnWidth: .5,
      layout: 'anchor',
      items: [{
        xtype: 'combobox',
        fieldLabel: 'Combo1',
        name: 'Combo1',
        store: store1,
        displayField: 'name',
        valueField: 'name',
        anchor: '96%',
        listeners: {
          select: function(combo, records) {
            Ext.Ajax.request({
              url: 'backend.java',
              method: 'GET',
              params: {
                "param2": combo.getValue()
              },
              success: function(response) {
                var data = Ext.Msg.decode(response.responseText);
                store2.loadData(data);
              }
            });
          }
        }
      }, {
        xtype: 'combobox',
        fieldLabel: 'Combo2',
        name: 'Combo2',
        id: 'Combo2',
        store: store2,
        displayField: 'someField',
        valueField: 'someField'

      }]

    }]
  }]


});

After some searching I found may be I have to listen to event change in combo2. Not sure if that's correct and if it is how would that work? So I guess my question is two folds. Firstly, why wouldn't the above code work? Secondly, is there a better/more elegant way of doing this.

EDIT

 var store2 = Ext.create('Ext.data.ArrayStore', {
   model: 'store2model',
   autoLoad: true,
   autoDestroy: true,
   storeId: 'store2Id',
    proxy: {
     type: 'ajax',
     url: 'backend.java'
   //  extraParams: {
     //  'param2': param2
    // },
     reader: {
       type: 'json'
     }

   }
 });
Michael Watson

Looks like you assigned store1 a proxy so that you can do a store1.load(), maybe try doing the same with store2.

So you could assign the url 'backend.java' as a proxy to store2, and when combo1 gets selected, you can load the store for combo2 with the value is a param.

  {
        xtype: 'combobox',
        fieldLabel: 'Combo1',
        name: 'Combo1',
        store: store1,
        displayField: 'name',
        valueField: 'name',
        anchor: '96%',
        listeners: {
          select: function(combo, records) {
            Ext.getCmp('Combo2').getStore().load({
                params: {
                  param2: combo.getValue()
                }
            });  
          }
        }
      },

That will load combo2's store with the param2 parameter. So just assign combo2's store whatever the proxy url is. Try that perhaps?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

dynamically change the combo box store in extjs

From Dev

Combo box click event not loading remote store

From Dev

How to fire onSelect of a extjs 3.4 combo when loading a Store?

From Dev

jquery easyui data grid editor for combo box not loading with grails

From Dev

Ajax Combo box with `Please Wait` label For Loading Data

From Dev

Dynamically loading combo box values

From Dev

rails combo box with dynamic values

From Dev

Dynamic loading in Extjs

From Dev

ExtJs 3.4 : Set tool tip for combo box

From Dev

Display combo box when checkbox is checked - Extjs

From Dev

Extjs how to add close icon to the combo box

From Dev

ExtJs 3.4 : Set tool tip for combo box

From Dev

store html data for dynamic ajax loading

From Dev

ExtJS - Store proxy loading data using Array Reader

From Dev

Extjs how to remove and undo list items from extjs combo box

From Dev

Binding data to a combo box in access

From Dev

Sencha Touch Combo Box using Model and Store

From Dev

How to list combo box data based on another combo box entry

From Dev

Extjs Combo - Why combo is loading while I have not created form include combo

From Dev

BIRT Combo Box dynamic default value

From Dev

Ajax for dynamic combo box selection in rails

From Dev

Live Search Combo Box Isn't Working ExtJS 4.2.1

From Dev

ExtJS/MODx CMP: grid edits not saving to db, combo box not displaying

From Dev

Live Search Combo Box Isn't Working ExtJS 4.2.1

From Dev

Force extjs combo box to have a minimum of one item?

From Dev

ExtJS/MODx CMP: grid edits not saving to db, combo box not displaying

From Dev

How to display html as text inside EXTJS combo box

From Dev

Extjs 4.1 - How to wait all store in combo is loaded

From Dev

Can´t load store of a combo in ExtJS4

Related Related

  1. 1

    dynamically change the combo box store in extjs

  2. 2

    Combo box click event not loading remote store

  3. 3

    How to fire onSelect of a extjs 3.4 combo when loading a Store?

  4. 4

    jquery easyui data grid editor for combo box not loading with grails

  5. 5

    Ajax Combo box with `Please Wait` label For Loading Data

  6. 6

    Dynamically loading combo box values

  7. 7

    rails combo box with dynamic values

  8. 8

    Dynamic loading in Extjs

  9. 9

    ExtJs 3.4 : Set tool tip for combo box

  10. 10

    Display combo box when checkbox is checked - Extjs

  11. 11

    Extjs how to add close icon to the combo box

  12. 12

    ExtJs 3.4 : Set tool tip for combo box

  13. 13

    store html data for dynamic ajax loading

  14. 14

    ExtJS - Store proxy loading data using Array Reader

  15. 15

    Extjs how to remove and undo list items from extjs combo box

  16. 16

    Binding data to a combo box in access

  17. 17

    Sencha Touch Combo Box using Model and Store

  18. 18

    How to list combo box data based on another combo box entry

  19. 19

    Extjs Combo - Why combo is loading while I have not created form include combo

  20. 20

    BIRT Combo Box dynamic default value

  21. 21

    Ajax for dynamic combo box selection in rails

  22. 22

    Live Search Combo Box Isn't Working ExtJS 4.2.1

  23. 23

    ExtJS/MODx CMP: grid edits not saving to db, combo box not displaying

  24. 24

    Live Search Combo Box Isn't Working ExtJS 4.2.1

  25. 25

    Force extjs combo box to have a minimum of one item?

  26. 26

    ExtJS/MODx CMP: grid edits not saving to db, combo box not displaying

  27. 27

    How to display html as text inside EXTJS combo box

  28. 28

    Extjs 4.1 - How to wait all store in combo is loaded

  29. 29

    Can´t load store of a combo in ExtJS4

HotTag

Archive