1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    61
    Vote Rating
    1
    dgherrig is on a distinguished road

      0  

    Default call sort on grid column after grid initially loaded

    call sort on grid column after grid initially loaded


    Hi,
    Have searched the forums for this but could not find anything.

    I was to sort my grid after its loaded.

    In the store.load callback function

    store.load({
    scope: this,
    callback: function(records, operation, success) {
    console.log(success);
    -->>>> some call here to call the ascending sort function for a give grid column
    }
    });
    After the grid has been loaded, I want to pragmatically call the ascending sort function for a give column.

    Any ideas or pointers is greatly appreciated, thanks in advance

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,413
    Vote Rating
    129
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Sort the store and the grid will dynamically update itself.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    61
    Vote Rating
    1
    dgherrig is on a distinguished road

      0  

    Default call sort on grid column after grid initially loaded:

    call sort on grid column after grid initially loaded:


    Thanks, for the fast reply, I did that, see below, it does indeed sort based on the Severity column when its initially loaded, however, it does not seem to honor the doSort I have overidden in my view and seems to sort on the default alphabetic sort. If I click on the severity column button after its been loaded, it sorts as expected. based on the doSort I have overidden.

    So everything appear to be working fine, except the doSort I have overriden in the view does not seem to be used on the "initial" load of the grid.

    the doSort is show below also,

    Code:
     constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: false,
                autoSync: true,
                filterOnLoad: false,
                storeId: 'MyJsonStore',
                model: 'MyApp.model.Alerts',
                purgePageCount: false,
                sorters: {
                    property: 'Severity'
                }
            }, cfg)]);
        }
    
    
     doSort : function(state) {
                       
                        var field = this.getSortParam();
                        var ds = this.up('gridpanel').store;
    
                        console.log('doSort field: ' + field );
                        ds.sort({
                            property : field,
                            direction : state,
                            sorterFn : function(v1, v2) {
    
                                v1 = v1.get(field);
                                v2 = v2.get(field);
    
                                var sevA = me.getSeverityNumber(v1);
                                var sevB = me.getSeverityNumber(v2);
                                var eq = (sevA == sevB ? 0 : (sevA > sevB ? 1 : -1));
                                return eq;
    
                            }
                        });
                    },
    Last edited by aconran; 24 Jul 2012 at 4:08 PM. Reason: add code tags

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,413
    Vote Rating
    129
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    The proper way to do this is at the data level with a custom sortType:
    http://docs.sencha.com/ext-js/4-1/#!...data.SortTypes

    Unfortunately we currently have a bug regarding using custom sortTypes within Sencha Architect.

    This will be added in the near future:
    http://www.sencha.com/forum/showthread.php?229975
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  5. #5
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    61
    Vote Rating
    1
    dgherrig is on a distinguished road

      0  

    Default call sort on grid column after grid initially loaded:

    call sort on grid column after grid initially loaded:


    Thanks, will be waiting for the bug fix.

Thread Participants: 1