1. #21
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    The configs are merged so why not have this:

    Code:
    config : {
        component : {
            xtype : 'textareainput'
        }
    }
    I definitely learned a lot today! Thanks Mitchell!!

  2. #22
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    There seems to be a little problem in this component when using a delimiter other then a comma (','). When doing a getValue() on the field you will always get back comma separated values like this: "aaaaa,bbbb,cccc", no matter what you set as a delimiter.

    The reason for this is that the selected item values are stored as an array and not as one string (like it is when the component is initialized).

    I found 3 places in the code that I had to modify in order to make it work with the delimiter of my choice ("; "). Two concern the Setter for the VALUE field. Right now the APPLY does return an array. Only in the UPDATE is the array converted into a string. Problem is that it is the APPLY that stores the new value in the VALUE field which will let getValue() fail. So I had to change that first:

    new applyValue():
    Code:
    applyValue: function(value) {
        this.getOptions();
        var value = this.getValueFromRecords(value,this.getValueField());
        value = this.convertValue(value, this.getValueField(), this.getDisplayField());
        return value.join(this.getDelimiter());
    },
    new updateValue():
    Code:
    updateValue: function(newValue, oldValue) {
        this.superclass.superclass.updateValue.call(this,[newValue]);
    },
    then there was a little conversion problem here (new code in blue):
    Code:
    getRecordsFromValue: function(value){
        var records = [],
             all = this.getStore().getRange(),
             valueField = this.getValueField(),
             i = 0,
             allLen = all.length,
             rec,
             j,
             valueLen;
    
        if(value){
            // value must be an array!
            if (!Ext.isArray(value)) {
                value = value.split(this.getDelimiter());
            }
            for (valueLen = value.length; i < valueLen; ++i) {
                for (j = 0; j < allLen; ++j) {
                    rec = all[j];
                    if (rec.get(valueField) == value[i]) {
                        records.push(rec);
                        break;
                   }
                }
            }
        }
        return records;
    },

  3. #23
    Sencha Premium Member vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Chisinau, Moldova
    Posts
    642
    Vote Rating
    25
    vadimv will become famous soon enough vadimv will become famous soon enough

      0  

    Default


    Hey @ingo.hefti

    Nothing is wrong with it, your change now makes getValue to return a string instead of an array. The delimiter is for visual purpose, and for splitting initial string value.
    Someone needs a string, someone an array - my use case was to send to server an array of ids.

    Having an array, easily you could get the string as you want by joining that array.

    Vadim.

  4. #24
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Quote Originally Posted by vadimv View Post
    Nothing is wrong with it, your change now makes getValue to return a string instead of an array. The delimiter is for visual purpose, and for splitting initial string value.
    Someone needs a string, someone an array - my use case was to send to server an array of ids.
    I see your point. Only it does not sound logical to me. I mean the component is intended to be used in forms. So the data type should not change between input and output. Just my 2 cents...

    But at the end it's your component and I still like it very much!

  5. #25
    Sencha User
    Join Date
    Apr 2013
    Posts
    19
    Vote Rating
    0
    Ant0nin is on a distinguished road

      0  

    Default


    Hello,

    I've made a derived class of the extension. However the list values do not appear in the field, but they appear in the list at the time of the selection.

    Code:
    Ext.define('DocuTouch.form.field.recherche.Liste', {
        extend:'Ext.field.Select',
        xtype: 'fieldrechercheliste',
        
        constructor: function(champ) {
            
            this.callParent();
            
            var storeListe = Ext.create('DocuTouch.store.ValeurListe', champ);
            
            this.setRecord(champ);
            this.setLabel(champ.get('nom'));
            this.setStore(storeListe);
        },
        
        config: {
            valueField: 'id',
            displayField: 'valeur',
            autoSelect: false,
            value: null
        }
    });
    What is wrong in my code ?

    Thanks in advance.

  6. #26
    Sencha User
    Join Date
    Nov 2010
    Posts
    395
    Vote Rating
    6
    gkatz is on a distinguished road

      0  

    Default


    is this still the only decent multi select out there for ST2.x? or are there other native or extension options?
    thanks!

  7. #27
    Sencha User
    Join Date
    Nov 2010
    Posts
    395
    Vote Rating
    6
    gkatz is on a distinguished road

      0  

    Default


    ---