Results 1 to 2 of 2

Thread: ComboBox values not in the store

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    1

    Default ComboBox values not in the store

    Hi guys, I can't solve my problem and I decided to post it here. There is my simple store store and combobox:
    data = [];
    for (i = 0,j = 0; i < 12; i++, j += 5)
    data.push({value: j , text: ''+j+ ' minutes'});
    Project.minutes = Ext.create('Ext.data.Store', {
    fields: ['value', 'text'],
    data : data
    });

    ...
    xtype: 'combo',
    emptyText: 'Minutes',
    store: Project.minutes,
    valueField: 'value',
    displayField: 'text',
    id: 'ActualDurationMinutes'
    ...
    The problem comes when I try to input a value different from these in the store and then reload the dialog window.

    Ext.getCmp('ActualDurationMinutes').getValue();
    RESULT: 2

    The Value is the same but it is not shown in the field and also brakes my validation. What I am supposed to do in this situation? Maybe try to add it dynamically in the store and after that remove it?
    dialog1.JPGdialog2.JPGdialog3.JPGdialog4.JPG

  2. #2
    Sencha Premium User twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    242
    Answers
    16

    Default

    Perhaps this might help:

    Code:
    Ext.onReady(function() {
    
        Ext.widget('combobox', {
            renderTo: Ext.getBody(),
            store: [1,5,10,15,30,45],
            forceSelection: false,
            autoSelect: false,
            displayTpl: '<tpl for=".">{[typeof values === "number" ? values : values["field1"]]} minutes</tpl>',
            listConfig: {
                getInnerTpl: function(displayField) {
                    return '{' + displayField + '} minutes';
                }
            },
            beforeBlur: function() {
                var me = this,
                    value = parseInt(me.getRawValue(),10);
                me.doQueryTask.cancel();
                if(value) {
                    me.setValue(value);
                }
                me.assertValue();
            }
        }).center();
    });
    It uses an array/store with numeric values. The 'minutes' text is only added for display purposes.
    combobox.png
    Last edited by twaindev; 25 Oct 2011 at 5:59 AM. Reason: Added image

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •