1. #1
    Ext User
    Join Date
    Jul 2007
    Posts
    14
    Vote Rating
    0
    mchrustek is on a distinguished road

      0  

    Default [SOLVED] Combobox and array as source

    [SOLVED] Combobox and array as source


    hello.
    How to load data into combobox directly from array?? What I mean is:

    Code:
    var numbers = new Ext.form.ComboBox({
    	fieldLabel: 'Choose number',
    	hiddenName:'number',
    	store: ['6', '7', '8', '9'],
    	displayField:'year',
    	typeAhead: true,
    	mode: 'local',
    	triggerAction: 'all',
    	emptyText:'Select value...',
    	selectOnFocus:true,
    	width:175
    });
    The value should be the selected number, that's I don't need a table with 'id' and 'value'.

    Greetings
    Mike
    Last edited by mchrustek; 12 Nov 2007 at 11:39 PM. Reason: solved

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    2
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    This has been added into 2.0 via the SimpleStore's expandData config value which expands a one-dimensional array into a record set that can be used by the store. In 1.1 there's nothing that directly supports this.

  3. #3
    Ext User
    Join Date
    Jul 2007
    Posts
    14
    Vote Rating
    0
    mchrustek is on a distinguished road

      0  

    Default


    Ok. .... this is how I solved my problem:

    Code:
    store: new Ext.data.SimpleStore({
        fields: ['number_id', 'number'],
        data : [['6','6'],['7','7'],['8','8']]
    }),
    If any suggestions how to make it simplier or more "correct" - I'll wait for opinions.
    And other thing - I wanted to modify this, to have data for combobox into some variable, but it doesn't work. Any idea how to do it??

    Code:
    (...)
    var nbs = "[['6','6'],['7','7'],['8','8']]"
    store: new Ext.data.SimpleStore({
        fields: ['number_id', 'number'],
        data : nbs
    }),
    Greetings
    Mike

    P.S.
    This forum is very helpful for me. I'm glad that into the discussions Core Developers are involved. I've already had resolved many of problems I found while 'studying' ExtJs. Thank you.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,949
    Vote Rating
    636
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You could write a 'make2d' method:

    Untested:
    Code:
    function make2d(arr)
    {
       //possible sanity checks on arr here.
       var out = [];
       for (var i = 0; i < arr.length; i++)
          out[i] = [arr[i], arr[i]];
    
       return out;
    }

  5. #5
    Ext User
    Join Date
    Jul 2007
    Posts
    14
    Vote Rating
    0
    mchrustek is on a distinguished road

      0  

    Default


    Thanks for cooperations and suggestion. It works.

    Mike

  6. #6
    Ext User
    Join Date
    Nov 2007
    Posts
    17
    Vote Rating
    0
    tschaub is on a distinguished road

      0  

    Default expandData not documented

    expandData not documented


    Quote Originally Posted by brian.moeskau View Post
    This has been added into 2.0 via the SimpleStore's expandData config value which expands a one-dimensional array into a record set that can be used by the store. In 1.1 there's nothing that directly supports this.
    I don't see expandData in the docs.

    Are these forums the only way issues are tracked? I see http://extjs.com/forum/showthread.ph...345#post119345, but am not sure if that is really supposed to be a bug report.

    Also, on the same topic, are patches appropriate here?

    Thanks for any tips on how to find if an issue has already been reported (and issue status).

    Tim