1. #1
    Sencha Premium Member
    Join Date
    Jun 2011
    Location
    Kaiserslautern, Germany
    Posts
    7
    Answers
    2
    Vote Rating
    0
    Kotolom is on a distinguished road

      0  

    Default Answered: Custom sort in tree column. Sorter in store impelmented, but the column uses its own

    Answered: Custom sort in tree column. Sorter in store impelmented, but the column uses its own


    hi all
    this is the code in tree store
    Code:
    Ext.define('data.store.AssetTreeStore', {
        extend: 'Ext.data.TreeStore',
            sorters: [
                          {
                              // natural sort                           
                             sorterFn:  function (rec1, rec2) {
                              <some code>
                         }
                        ]
    ...
    });
    When the tree is first time loaded (on page load) the items are sortet using the sorter I implemented in store. But when I click on the header the tree uses its own sorter.

    What I'm doing wrong?

  2. I've got it.

    I have to add the 'sort' function to the store.

    Code:
        sort: function(sorters, direction) {
            var me = this;
    
            if(sorters && sorters.property == 'title') {
                if(sorters.direction == 'ASC') {
                    return this.doSort(function(rec1, rec2) {
                        return Util.String.compareNatural(rec1.get('title'), rec2.get('title'));
                    });
                } else {
                    return this.doSort(function(rec1, rec2) {
                        return -Util.String.compareNatural(rec1.get('title'), rec2.get('title'));
                    });
                }
            }
    
            return me.callParent(arguments);
        }

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    When you click on the tree grid column header, it will only use the one sorter based on the header. It won't add a sort to the existing array of sorters.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha Premium Member
    Join Date
    Jun 2011
    Location
    Kaiserslautern, Germany
    Posts
    7
    Answers
    2
    Vote Rating
    0
    Kotolom is on a distinguished road

      0  

    Default


    Well, that's clear to me.
    But when you look at this example http://jsfiddle.net/cvdNW/3/
    you will find the sort implemented in store and used on header click.

    So the right question is: how can I use a custom sort on header click in a tree column?
    And I can't apply it to a field in the model, because this would affect other components thas are using the model.

    All solutions I found use the store to impelment a custom sort.

  5. #4
    Sencha Premium Member
    Join Date
    Jun 2011
    Location
    Kaiserslautern, Germany
    Posts
    7
    Answers
    2
    Vote Rating
    0
    Kotolom is on a distinguished road

      0  

    Default


    I've got it.

    I have to add the 'sort' function to the store.

    Code:
        sort: function(sorters, direction) {
            var me = this;
    
            if(sorters && sorters.property == 'title') {
                if(sorters.direction == 'ASC') {
                    return this.doSort(function(rec1, rec2) {
                        return Util.String.compareNatural(rec1.get('title'), rec2.get('title'));
                    });
                } else {
                    return this.doSort(function(rec1, rec2) {
                        return -Util.String.compareNatural(rec1.get('title'), rec2.get('title'));
                    });
                }
            }
    
            return me.callParent(arguments);
        }

Thread Participants: 1

Tags for this Thread

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..." hd porno faketaxi