[CLOSED] MultiCombo Order

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] MultiCombo Order

    Last edited by Daniil; May 15, 2013 at 9:45 AM. Reason: [CLOSED]
  2. #2
    Hi @softmachine2011,

    Please try to set up
    SortByValueField="true"
    for the MultiCombo and add the following override to the page's <head>.

    Does it help?

    Override
    Ext.net.MultiCombo.override({
        setValue : function (value, doSelect) {
            var me = this,
                matchedRecords,
                nonRecords;
    
            if (me.sortByDisplayField || me.sortByValueField) {
                value = Ext.Array.from(value);
                matchedRecords = [];
                nonRecords = [];
                Ext.each(value, function (v) {
                    record = v;
                    if (!record || !record.isModel) {
                        record = me.findRecordByValue(record);
                    }
    
                    if (record) {
                        matchedRecords.push(record);
                    } else {
                        nonRecords.push(v);
                    }
                });
    
                Ext.Array.sort(matchedRecords, function (r1, r2) {
                    var v1 = r1.get(me.sortByDisplayField ? me.displayField : me.valueField),
                        v2 = r2.get(me.sortByDisplayField ? me.displayField : me.valueField);
                                
                    if (v1 === v2) {
                        return 0;
                    }
                            
                    return v1 > v2 ? 1 : -1;
                });
    
                value = matchedRecords.concat(nonRecords);
            }
    
            me.callParent(arguments);
    
            Ext.each(this.valueModels, function (r) {
                this.selectRecord(r);
            }, this);
        }    
    });
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @softmachine2011,

    Please try to set up
    SortByValueField="true"
    for the MultiCombo and ...[/CODE]
    I'm using Ext.NET 2.1 r4377 and SortByValueField doesn't exists, only SortByDisplayField property.
    I tried to use your code but seems that doesn't work as expected, possibly because property that you mention doesn't exists.
  4. #4
    Setting up a non-existing property via markup is interpreted as a custom config, i.e. it is a shorthand of CustomConfig. So, it is OK.

    The override doesn't make sense without SortByValueField="true". So, did you try it with this setting or without?
  5. #5
    Yes, using this code and property passed as customConfig, works as expected

    Thanks
  6. #6
    Hello!

    Can you confirm that your problem has been solved and we can close this thread?
  7. #7
    Yes, like I say it works as expected, you can close thread.
  8. #8
    We committed the change to SVN. It will also go to the next release.

    So, you will be able to remove the override and use a MultiCombo's SortByValueField instead of using its CustomConfig.

    Thank you for the question!
  9. #9
    Ok, thanks for your effort.
  10. #10
    I noticed that you are using a global variable named record in this lines of your fix:
    Ext.each(value, function (v) {
                    record = v;
    It would be better to declare it as
    Ext.each(value, function (v) {
                    var record = v;
    record is a common name for a variable in this framework and could break a lot of things .
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Order GridPanel Groups in an arbitrary order?
    By dmoore in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 27, 2013, 4:35 AM
  2. Multicombo or Multiselect with sequence order
    By Birgit in forum 2.x Help
    Replies: 4
    Last Post: Nov 28, 2012, 7:18 AM
  3. Replies: 0
    Last Post: Aug 24, 2011, 12:13 AM
  4. Button order
    By ankit in forum 1.x Help
    Replies: 2
    Last Post: Jun 14, 2010, 12:27 PM
  5. Render Order
    By Ben in forum 1.x Help
    Replies: 3
    Last Post: Jun 12, 2008, 6:33 AM

Tags for this Thread

Posting Permissions