1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    34
    Answers
    4
    Vote Rating
    0
    mkrakowski is on a distinguished road

      0  

    Default Unanswered: Combobox turns into input field

    Unanswered: Combobox turns into input field


    Hi all,

    I have a method that converts an array into a store (upgrading from Ext 3.4 to 4.1). Problem is that when rendered, the xtype : combo is converted to a a regular input field, not sure why this is occurring.

    Here's my code..

    Function call to assoc_array_to_simple_store...

    PHP Code:
    var field_merchant_supporting_merchant_id = {
      
    id id,
      
    xtype 'combo',
      
    fieldLabel 'Merchant',
      
    store TOP.assoc_array_to_simple_store({  // <--- convert array into store
        
    key 'id'
        
    label 'name'
        
    data TOP.page_vars['merchants'], 
        
    prefixAll true
        
    prefixAllKey '0'
        
    prefixAllLabel 'Select Merchant'
      
    }),
    triggerAction 'all',
    valueField 'key',
    displayField 'label',
    queryMode 'local',
    typeAhead true,
    selectOnFocus true,
    forceSelection true,
    value value,
    width 250,

    [...] 
    Array to store function
    PHP Code:
    assoc_array_to_simple_store: function(options) {
     
    // Define store model
     
    Ext.define('simplestoreModel', {
     
    extend  'Ext.data.Model',
     
    fields  : ['key''label']
     });
     
     
    options objMerge({
       
    model 'simplestoreModel',
       
    key null,
       
    label null,
       
    data: {},
       
    prefixAll true,
       
    prefixAllKey'0',
       
    prefixAllLabel 'All'
     
    }, options || {});
     
     
    // build the data object
     
    var data = [];
     if (
    options.prefixAll) {
      var 
    prefixRow = { key options.prefixAllKeylabel options.prefixAllLabel };
      
    data.push(prefixRow); //data.push([options.prefixAllKey, options.prefixAllLabel]);
     
    }
     if (!
    isEmptyObj(options.data)) {
      
    Ext.iterate(options.data, function(keyo) {
         if (
    typeof o == 'string') {
           var 
    rowKey key;
           var 
    rowLabel o;
           var 
    dataRow = { key rowKeylabel rowLabel };
        } else {
          var 
    rowLabel o[options.label];
          var 
    rowKey   o[options.key];                      
          var 
    dataRow = { key rowKeylabel rowLabel };
       }
        if (!
    Ext.isEmpty(rowKey) && !Ext.isEmpty(rowLabel)) {
          
    data.push(dataRow); // data.push([rowKey, rowLabel]);
        
    }
     });
     }
      
      return 
    Ext.create('Ext.data.Store', { //new Ext.data.SimpleStore({
         
    model  'simplestoreModel',
         
    data   data,
         
    proxy  : { type 'memory' }
      });
    },

    [...] 
    Firebug..
    Code:
    console.log(data); // Is something wrong with the format of this object?
    
    [Object { key="0",  label="Select Interval Unit"}, Object { key="days",  label="Day"}, Object { key="weeks",  label="Week"}, Object { key="months",  label="Month"}, Object { key="years",  label="Year"}]
    
    //
    //
    This function was previously working correctly in Ext 3.4, here's the same object output (in Ext 3.4).

    Using this object (Ext 3.4 formatted) in Ext 4 generates the combo boxes with the correct number of drop down menus, however they are "blank values". Adding "key" and "label" to the array in Ext 4 renders an input textfield with the first value.

    Code:
    console.log(data);
    
    [["0", "Select Interval Unit"], ["days", "Day"], ["weeks", "Week"], ["months", "Month"], ["years", "Year"]]
    
    //

    So all I'm doing different is adding the "key" and "label" whereas before it was just the key value, and label value.

    Code:
    { key : rowKey, label : rowLabel }
    This is what I'm seeing (combo boxes are converted to input fields)

    Screen Shot 2013-04-10 at 10.39.07 AM.png



    What I was previously seeing in Ext 3.4

    Screen Shot 2013-04-10 at 10.39.34 AM.png


    Thanks!

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,470
    Answers
    442
    Vote Rating
    202
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    Can you post a working example snippet that demonstrates the issue? Based on what you've posted so far I'm unsure what's causing your issue.

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    34
    Answers
    4
    Vote Rating
    0
    mkrakowski is on a distinguished road

      0  

    Default


    I've narrowed it down to it being values from the [key] because when I set a dummy key variable with static text (e.g. var myKey = 'sometext') it populates fine (ofcourse you cannot preselect nor save data). When I inspect the dynamic key values in firebug, nothing looks out of the ordinary, but it could be a back-end issue.

Thread Participants: 1