Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

EXTJS Combobox problems

  1. Feb 9, 2016 #1
    I am creating the following combobox:


    Code (Text):

    //stations store
      var stationStore = Ext.create('Ext.data.Store', {
          id: 'stationStore',
          fields:[{name: 'station'}]
      });
     
    the store is build on app load, and is empty to start. At this point the combobox is hidden Once the user runs a search and the ajax call is successful, the returndata is processed and all of the stations are added to the store in the success callback:

    Code (Text):

     success: function (data) {
                      for (var i = 0; i < data.length; i++) {
                          var store = Ext.StoreMgr.lookup("stationStore");
                          store.insert(i, data[i].stationID);
                      }
                      console.log('success');
                  },
     
    Code (Text):

    // Create the combo box, attached to the stations data store
      var stationCombo = Ext.create('Ext.form.ComboBox', {
          id: 'stationCombo',
          emptyText: 'Choose Station',
          store: stationStore,
          queryMode: 'local',
          displayField: 'station',
          valueField: 'station',
          hidden: true
      });
      tb.add(stationCombo);
    The combobox is then displayed and the user is able to select a station from the list. The store has data added into it, and the list is populated, but when you click the dropdown, the list items are so small it looks like a line when you select from the list...

    upload_2016-2-9_16-41-52.png
     
  2. jcsd
  3. Feb 9, 2016 #2

    jedishrfu

    Staff: Mentor

  4. Feb 10, 2016 #3
    I figured out what the problem was, so in case someone else runs across this post, here is the fix...
    Code (Javascript):

    success: function (data) {                
       for (var i = 0; i < data.length; i++) {                    
          var store = Ext.StoreMgr.lookup("stationStore");                    
          store.insert(i, {'station' : data[i].stationID});  //<--This line was wrong, the store takes an object, not a string
       }                  console.log('success');            
    },
     
    the store takes an OBJECT. I was trying to insert a string, so it was getting the values, but the store couldn't handle just the string. Changing the insert to insert an object instead of a string fixed the problem.
     
  5. Feb 10, 2016 #4

    jedishrfu

    Staff: Mentor

    THanks for posting your solution too! So many times threads are left dangling without answers.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: EXTJS Combobox problems
  1. Problems with zheev (Replies: 4)

  2. Javascript problem (Replies: 6)

  3. Problem with dgesv (Replies: 5)

  4. Problem with Excel (Replies: 4)

  5. Reduction problem (Replies: 8)

Loading...