Results 1 to 4 of 4

Thread: TagField TypeError with multiSelect: false

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-19271 in 6.0.2.
  1. #1
    Sencha Premium User
    Join Date
    Jun 2012
    Posts
    48

    Default TagField TypeError with multiSelect: false

    When using the multiSelect: false config in a TagField, Ext 6.0.1. throws a TypeError: value is null at line 180388 of ext-all-debug.js.

    Fiddle: https://fiddle.sencha.com/#fiddle/ua6


    Ext version tested:
    • Ext 6.0 rev 1

    Browser versions tested against:
    • Chrome 45
    • IE 11
    • FF 40

    DOCTYPE tested against:
    • Strict
    • Quirks
    • HTML5

    Description:
    • Using the multiSelect: false config in a TagField results in a TypeError: value is null at line 180388 of ext-all-debug.js. This happens regardless of the query mode and store type (e.g., simple array or array of objects).

    Steps to reproduce the problem:
    • See Sencha Fiddle: use multiSelect: false config property .
    • Alternativcely, in the API documentation for TagField, edit the sample code to add multiSelect: false and run.

    The result that was expected:
    • A TagField that allows selecting a single item.

    The result that occurs instead:
    • Error

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report. This issue is being tracked as EXTJS-19271.

  3. #3

    Default

    Workaround
    Just add to overrides folder.

    Code:
    Ext.define('Override.form.field.Tag', {    
        override: 'Ext.form.field.Tag',
    
    
        setValue: function(value, /* private */ add, skipLoad) {
            var me = this,
                valueStore = me.valueStore,
                valueField = me.valueField,
                unknownValues = [],
                store = me.store,
                autoLoadOnValue = me.autoLoadOnValue,
                isLoaded = store.getCount() > 0 || store.isLoaded(),
                pendingLoad = store.hasPendingLoad(),
                unloaded = autoLoadOnValue && !isLoaded && !pendingLoad,
                record, len, i, valueRecord, cls, params;
    
    
            if (Ext.isEmpty(value)) {
                value = Ext.Array.from(value, true); // NEW
            }
            else if (Ext.isString(value) && me.multiSelect) {
                value = value.split(me.delimiter);
            }
            else {
                value = Ext.Array.from(value, true);
            }
    
    
            if (value && me.queryMode === 'remote' && !store.isEmptyStore && skipLoad !== true && unloaded) {
                for (i = 0, len = value.length; i < len; i++) {
                    record = value[i];
                    if (!record || !record.isModel) {
                        valueRecord = valueStore.findExact(valueField, record);
                        if (valueRecord > -1) {
                            value[i] = valueStore.getAt(valueRecord);
                        } else {
                            valueRecord = me.findRecord(valueField, record);
                            if (!valueRecord) {
                                if (me.forceSelection) {
                                    unknownValues.push(record);
                                } else {
                                    valueRecord = {};
                                    valueRecord[me.valueField] = record;
                                    valueRecord[me.displayField] = record;
    
    
                                    cls = me.valueStore.getModel();
                                    valueRecord = new cls(valueRecord);
                                }
                            }
                            if (valueRecord) {
                                value[i] = valueRecord;
                            }
                        }
                    }
                }
    
    
                if (unknownValues.length) {
                    params = {};
                    params[me.valueParam || me.valueField] = unknownValues.join(me.delimiter);
                    store.load({
                        params: params,
                        callback: function() {
                            me.setValue(value, add, true);
                            me.autoSize();
                            me.lastQuery = false;
                        }
                    });
                    return false;
                }
            }
    
    
            // For single-select boxes, use the last good (formal record) value if possible
            if (!me.multiSelect && value.length > 0) {
                for (i = value.length - 1; i >= 0; i--) {
                    if (value[i].isModel) {
                        value = value[i];
                        break;
                    }
                }
                if (Ext.isArray(value)) {
                    value = value[value.length - 1];
                }
            }
    
    
            return me.callSuper([value, add]); // NEW
        }
    
    
    });

  4. #4

    Default

    The fix above works for fields where you want multiSelect: false.


    My tagfield is initially set to multiSelect: false and based on other conditions i want to make it true. I set the multiselect property dynamically. The override code is called on initial load and not any any event. Is it possible to dynamically switch from single valued tagfield and multi valued?

Similar Threads

  1. [OPEN] TagField setValue not showing value for multiSelect [ExtJS 6.0.0]
    By A. Llorente in forum Ext JS 6.x Bugs
    Replies: 16
    Last Post: 10 May 2017, 11:14 PM
  2. TagField setValue not showing value for multiSelect [ExtJS 6.0.0]
    By A. Llorente in forum Sencha Ext JS Q&A
    Replies: 2
    Last Post: 25 Aug 2015, 1:39 AM
  3. [FIXED] Tagfield with allowblank false always returns errors
    By joepitz in forum Ext 5: Bugs
    Replies: 1
    Last Post: 25 Mar 2015, 11:49 AM
  4. [OPEN] Fieldreplicator with Tagfield / Multiselect does not work
    By t.nissen in forum Ext 5: Bugs
    Replies: 1
    Last Post: 18 Feb 2015, 2:35 PM
  5. [OPEN] [5.0.2] Can't change multiSelect dynamically on ComboBox/Tagfield anymore
    By run_development in forum Ext 5: Bugs
    Replies: 2
    Last Post: 20 Nov 2014, 3:46 AM

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
  •