1. #1
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,561
    Vote Rating
    384
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default How to cancel grid sorting?

    How to cancel grid sorting?


    Currently, if you click a column header the grid gets sorted by this column. If you click again the sort order is reversed.

    Is there any possibility to NOT-to-sort. In another words, how do I cancel sort (after click of col header) without clicking another column to revert to original sort order?

    Note: I have remoteSort: true.

  2. #2
    Ext Premium Member BernardChhun's Avatar
    Join Date
    Mar 2007
    Location
    Quebec, Canada
    Posts
    831
    Vote Rating
    2
    BernardChhun will become famous soon enough

      0  

    Default


    I tried different things with the grid's dataSource and I can't seem to block it at will either. I'm interested in how this could be done

  3. #3
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    disable sorting then.

  4. #4
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,561
    Vote Rating
    384
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    You haven't got my point. I need:
    1. ASC
    2. DESC
    3. NONE

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    51
    Vote Rating
    0
    FlexIDX is on a distinguished road

      0  

    Default


    I need this feature as well, I have several fields/columns and want some to be sortable and some to not be sortable I would really like to be able to turn it off or on, on a per column basis.

    Chris

  6. #6
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,561
    Vote Rating
    384
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Yeah, reading your answer it comes to my mind that once I implemented in PHP sorting by more than one column. It worked like this:

    1. Click one column = toggle asc/desc
    2. Shift+Click the same column = no sort/sort off
    3. Shift+Click another column = add that column to order by field list
    4. Shift+Click that another column again = toggle that another column asc/desc
    5. Simple click a column after sorted by multiple another columns = turn off sorting by others and do point 1.

    It would be nice to have same feature in Ext, although, now it's not make/break point in the app I'm developing.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  7. #7
    Sencha Premium Member Troy Wolf's Avatar
    Join Date
    May 2007
    Location
    Kansas City
    Posts
    251
    Vote Rating
    2
    Troy Wolf is on a distinguished road

      0  

    Default


    It is interesting to me that this thread has not gone anywhere. I have a very similar issue with column sorting, but as it pertains to v2.0, I'll post a new thread in the 2.0 Help forum.

  8. #8
    Sencha User
    Join Date
    Apr 2007
    Location
    Italy/UK
    Posts
    152
    Vote Rating
    0
    sj137 is on a distinguished road

      0  

    Thumbs up a solution

    a solution


    I've just had to implement this in a v1.1 app, here's how i did it:

    firstly... add an extra named object thingy to your records definition... something like 'originalOrder' has been added below:

    NB XmlStringReader is a custom class that i extended from Ext.data.XmlReader

    PHP Code:
    var myRecordExt.data.Record.create([
            {
    name'somefield1'type'string'},
            {
    name'somefield2'type'int'},
            {
    name'originalOrder'type'int'//add extra field here...
        
    ]);

    var 
    gridXMLStringReader = new Ext.data.XmlStringReader({
              
    record'theXMLTagName'
         
    }, myRecord);

    var 
    myGridDataStore = new Ext.data.Store({
               
    proxy: new Ext.data.HttpProxy({urlmyURL}),
               
    readergridXMLStringReader
    });

    var 
    myGrid = new Ext.grid.EditorGrid('myGridsDiv', {
                    
    dsmyGridDataStore ,
                    
    cmmyGridColModel,
                    
    selModel: new Ext.grid.RowSelectionModel(),
                    
                    
    rememberSortOrder:true//add this to all the grids you want to enable this feature
                    
                    
    etc., etc., 
    }); 

    ok now, override handleHeaderClick in Ext.grid.GridView:
    we are adding the if statement:
    if (this.ds.getSortState() == null && this.grid.rememberSortOrder) {this.RememberSortOrder();}

    and the function RememberSortOrder()

    NB this.ds.getSortState() == null when the store is being sorted for the first time...
    ie the first time you click a column's header...

    RememberSortOrder() simply populates the originalOrder field of each record sequentially creating an index ;-)

    PHP Code:

    Ext
    .override(Ext.grid.GridView, {

        
    /* This overrides the default header click and adds a call to remember the previous sort order */
        
    handleHeaderClick : function(gindex) {
            if (
    this.headersDisabled) {
                return;
            }
            var 
    dm g.dataSourcecm g.colModel;
            if (!
    cm.isSortable(index)) {
                return;
            }
            
    g.stopEditing();
            if (
    this.ds.getSortState() == null && this.grid.rememberSortOrder) { this.RememberSortOrder();} //if the header hasn't been clicked before
            
    dm.sort(cm.getDataIndex(index));
        },

        
    RememberSortOrder : function() {
            var 
    order 1;
            
    this.ds.each(function(record) {
                
    record.data.originalOrder order;
                
    order++;
            });
        }
    }); 


    so far easy... and so is the rest ;-) ...read on

    Create two functions: "UnSort" & "SaveSort"

    PHP Code:

                
    function UnSort() {
                    
    myGridDataStore.each(function(rec) {
                        if (!
    rec.data.originalOrder) {rec.data.originalOrder 0;}
                    });
                    
    myGridDataStore.sort("originalOrder""ASC");
                    var 
    count 0;
                    
    myGridDataStore.each(function(rec) {
                        if (
    rec.data.originalOrder == 0) {
                            
    Ext.fly(myGrid.getView().getRow(count)).highlight("ff9999", {attr:'background-color'duration:3});
                            
    count++;
                        }
                    });
                }

                function 
    SaveSort() {
                    var 
    order 1;
                    
    myGridDataStore.each(function(rec) {
                        
    rec.data.originalOrder order;
                        
    order++;
                    });
                } 
    SaveSort basically re-indexs the grid, in case you want to change the order and make a save point...

    UnSort basically reverts the rows back to the original or saved order... and any new rows added will appear at the top and will be highlighted in red.

    Obviously this way-of-doing-it won't suit everyone, but it was enough for me, so hope it helps someone else too.

    long live EXT ;-)

    NB this hasn't been exhaustively tested yet and it may not be the best method to do this but i found it easy to understand and implement so i guess it will be the same for other newbie's :-)

  9. #9
    Ext User
    Join Date
    Jul 2009
    Location
    Madrid
    Posts
    3
    Vote Rating
    0
    pwnfactory is on a distinguished road

      0  

    Default


    Quote Originally Posted by jsakalos View Post
    You haven't got my point. I need:
    1. ASC
    2. DESC
    3. NONE
    Did you find a solution for this? We're looking for the same thing. Thanks

  10. #10
    Sencha User
    Join Date
    Oct 2011
    Posts
    35
    Vote Rating
    2
    ejerrywest is on a distinguished road

      0  

    Default Does this exist in 4.1 yet?

    Does this exist in 4.1 yet?


    I also need the same thing, I can't seem to find it in the 4.1 docs. I could have missed something though, does anyone know if this exists yet?