Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User mjoksa's Avatar
    Join Date
    Jun 2007
    Posts
    73
    Vote Rating
    0
    mjoksa is on a distinguished road

      0  

    Default [CLOSED][3.??]ComboBox with strings in ArrayStore and empty item issue...

    [CLOSED][3.??]ComboBox with strings in ArrayStore and empty item issue...


    Hello,
    I just discovered issue mentioned in title. I have created combo as shown in below code
    Code:
    StatusStore = function() {
        var data = [
            ['', ''],
            ['0', 'In-Active'],
            ['1', 'Active']
        ];
        var store = new Ext.data.ArrayStore({
            idIndex: 0,
            fields: ['value', 'name'],
            data: data
        });
        return store;
    } ();
    StatusCombo = function(config) {
        var defaultConfig = {
            emptyText: '[None]',
            tpl: '<tpl for="."><div class="x-combo-list-item">{name:defaultValue("&nbsp;")}</div></tpl>',//HACK: Render empty value in valid height. See: http://extjs.com/forum/showthread.php?t=65803&highlight=combobox+empty+text
            name: 'StatusID',
            hiddenName: 'StatusID',
            displayField: 'name',
            valueField: 'value',
            forceSelection: true,
            editable: false,
            fieldLabel: 'Status',
            store: StatusStore,
            triggerAction: 'all',
            mode: 'local',
            anchor: '-24'
        };
        Ext.applyIf(config, defaultConfig);
        return new Ext.form.ComboBox(config);
    };
    When setValue(0) method is called, combo will set its value to an empty item (first item in ArrayStore). This happens because JavaScript is weakly typed and comparison like 0 == '' will return true.
    To overcome this issue I had to override findRecord method in ComboBox with code below:
    Code:
    Ext.override(Ext.form.ComboBox, {
            findRecord: function(prop, value){
                var record;
                if(this.store.getCount() > 0){
                    this.store.each(function(r){
                        if ((typeof(r.data[prop]) == 'string' && typeof(value) == 'number' && r.data[prop] == '') ||
                           (typeof(r.data[prop]) == 'number' && typeof(value) == 'string' && value == '')) {
                            if(value === r.data[prop]) {
                                record = r;
                                return false;
                            }
                        }
                        else {
                            if(r.data[prop] == value){
                                record = r;
                                return false;
                            }
                        }
                    });
                }
                return record;
            }
        });
    Can anyone from Ext team confirm this and inform community if this is going to be fixed in next revision of framework.

    Cheers

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,781
    Vote Rating
    599
    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 use strict equivalance (===), but that ~still~ won't solve your problem, because '' nor '0' === 0. At this point it's probably not likely we'll fix this, you should pass in the appropriate value for your store to ensure that you get an appropriate match.

    Marking this as closed.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1

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..."