Results 1 to 2 of 2

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

    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
    Vote Rating

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

    I just discovered issue mentioned in title. I have created combo as shown in below code
    StatusStore = function() {
        var data = [
            ['', ''],
            ['0', 'In-Active'],
            ['1', 'Active']
        var store = new{
            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:
            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:
    Ext.override(Ext.form.ComboBox, {
            findRecord: function(prop, value){
                var record;
                if( > 0){
                        if ((typeof([prop]) == 'string' && typeof(value) == 'number' &&[prop] == '') ||
                           (typeof([prop]) == 'number' && typeof(value) == 'string' && value == '')) {
                            if(value ===[prop]) {
                                record = r;
                                return false;
                        else {
                            if([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.


  2. #2
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Sydney, Australia
    Vote Rating


    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.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

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