[CLOSED] ComboBox Question

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] ComboBox Question

    Hello,

    Was just wondering how one would do the following:

    1. Add items to a combobox that is not bound to a store, after render
    2. Remove all items from a combobox that is not bound to a store

    I don't see a context for .items in JavaScript.

    Cheers,
    Timothy
    Last edited by Daniil; Jun 12, 2012 at 4:22 PM. Reason: [CLOSED]
  2. #2
    Hi,

    If you set up Items for the ComboBox it will cause a simple Store will be created internally. So, all the same there is a Store and all ComboBox items should be there.

    So, there are no items in ComboBox "that is not bound to a store".

    Please provide more details about the requirement. Maybe we could suggest something.
  3. #3
    Hi Timothy,

    I'll just a few comments to @daniil's.

    The .Items Collection of a ComboBox creates a Store client-side. We just create the Store behind-the-scenes and there is always as Store+ComboBox if you add any .Items.

    The Store is there (client-side), and you can always get an instance of that store by calling .getStore() on the ComboBox.

    Example

    var store = App.ComboBox1.getStore();
    Hope this help.
    Geoffrey McGill
    Founder
  4. #4
    Thanks, I noticed this yesterday after I asked ... should have known from the Sencha docs, I didn't see any reference to items. What is the default structure of the store if you use items? For example, how would I get the text and value from a record in the store?

    Cheers,
    Timothy
  5. #5
    Try this
    var valueOfFirstRecord = combo.store.getAt(0).get(combo.valueField);
    var textOfFirstRecord = combo.store.getAt(0).get(combo.displayField);
  6. #6
    Answering this question:
    Quote Originally Posted by Timothy View Post
    What is the default structure of the store if you use items?
    The markup below:
    <ext:ComboBox runat="server">
        <Items>
            <ext:ListItem Text="Item 1" Value="1" />
            <ext:ListItem Text="Item 2" Value="2" />
        </Items>
    </ext:ComboBox>
    produces the JavaScript code like this
    Ext.onReady(function () {
        Ext.create("Ext.form.field.ComboBox", {
            id : "ctl04",
            renderTo : "App.ctl04_Container",
            queryMode : "local",
            triggerAction : "all",
            store : [
                ["1", "Item 1"],
                ["2", "Item 2"]
            ]
        });
    });
    Please see the ComboBox store docs article how consider a multi-dimensional array as the value of the "store" config option.
    http://docs.sencha.com/ext-js/4-1/#!...oBox-cfg-store
  7. #7
    How come the following doesn't work on the store:

    							store.add( [
    								record.get(parent.displayField),
    								record.get(parent.valueField)
    							] );
    I see the store is defined as:

    store:[["Value 1", "Item 1"]]
    I thought the above code would have worked. Any suggestions?

    Cheers,
    Timothy
  8. #8
    I think the following should work.
    var rec;
    rec[parent.displayField] = record.get(parent.displayField);
    rec[parent.valueField] = record.get(parent.valueField);
    store.add(rec);
    Please also clarify is the "record" not already bound to the ComboBox Store?
  9. #9
    Quote Originally Posted by Daniil View Post
    Please also clarify is the "record" not already bound to the ComboBox Store?
    Correct, at the moment the ComboBox is empty.

    Cheers
  10. #10
    Quote Originally Posted by Daniil View Post
    I think the following should work.
    var rec;
    rec[parent.displayField] = record.get(parent.displayField);
    rec[parent.valueField] = record.get(parent.valueField);
    store.add(rec);
    Your example returns

    can't convert undefined to object
    
    temp[parent.displayField] = record.get(parent.displayField);
    Cheers
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] question about combobox refresh
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 10
    Last Post: Jun 18, 2012, 2:02 PM
  2. [CLOSED] Question about the ComboBox....
    By RCN in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 09, 2012, 1:12 PM
  3. [CLOSED] Combobox Type Ahead Selection Question
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 22, 2009, 10:08 AM
  4. Hello, ComboBox Remote Query Question
    By bruce in forum 1.x Help
    Replies: 0
    Last Post: Mar 12, 2009, 10:55 PM
  5. Combobox validating question
    By bruce in forum 1.x Help
    Replies: 0
    Last Post: Mar 09, 2009, 1:08 AM

Posting Permissions