1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    3
    Vote Rating
    0
    dannilsson is on a distinguished road

      0  

    Default Adding items to a select field dynamically

    Adding items to a select field dynamically


    Hi,

    Scenario
    I have a select field with predefined items. When I choose an item from the list a new item should be added to the list. If I could clone the selected item somehow and just change the value attribute that would work.

    Problem
    I have successfully managed to add items dynamically as described above. The problem is that they are not "valid" items. Looking at the predefined items in Chrome I can see "c"-objects, or whatever they are (components?), with data, events and everything. When I add items using either setOptions or adding to the store they just show up as regular objects, no events. This causes problems later when I need to fetch values/change the items.

    Anyone have a solution for this? Yes, I have searched for answers, but haven't found anything.

    Thanks.

  2. #2
    Touch Premium Member
    Join Date
    Mar 2011
    Posts
    17
    Vote Rating
    1
    alanr1 is on a distinguished road

      1  

    Default


    can you call myselectfield.setOptions( ???

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    3
    Vote Rating
    0
    dannilsson is on a distinguished road

      0  

    Default


    Yes, but that does not work as I want it to. As I described in my post, the new items are not the same as the predefined ones. They are missing event handlers and a bunch of other stuff.

    Am I missing a magic select.update() call of some kind?

  4. #4
    Touch Premium Member
    Join Date
    Mar 2011
    Location
    New Jersey, USA
    Posts
    130
    Vote Rating
    0
    jjerome is on a distinguished road

      0  

    Default


    How to you set up your new options? Is it a JSON object? (i.e. {text: 'displayvalue', value: '0'} )

    And,
    does your selectfield have a listener for the 'change' event?

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    3
    Vote Rating
    0
    dannilsson is on a distinguished road

      0  

    Default


    Here's the code I'm using:

    Code:
                    xtype: "selectfield",
                    id: "bla",
                    name: "blabla",
                    label: "Label",
                    options: data, <-- array with {text, value} entries
                    listeners: {
                        change: function (field, value) {
                                field.setOptions([{
                                    value: "newvalue",
                                    text: "My new value"
                                }], true);
                            }
                        }
                    }
    Last edited by dannilsson; 12 Aug 2011 at 1:47 AM. Reason: Fixed code

  6. #6
    Sencha User
    Join Date
    Mar 2013
    Posts
    2
    Vote Rating
    0
    Harikrishnanp is on a distinguished road

      0  

    Default


    It worked for me. thanks

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi