1. #1
    Ext User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    madamut is on a distinguished road

      0  

    Default [CLOSED][2.2.x] sort grid with remoteSort: true and horizontal scroll bar

    [CLOSED][2.2.x] sort grid with remoteSort: true and horizontal scroll bar


    This is a minor issue, still, I'd like it to be fix, so here it goes, (I'm using ExtJS 2.2):

    I have a grid with the remoteSort: true set on the store. Also the grid shows a horizontal scroll bar. I noticed there is a difference in which the grid behaves when sorting by a column which is not visible initially (we need to scroll to the right to see it) when remoteSort is present or not.

    Basically what happens is that when remoteSort is missing and I click on the column header, the table is sorted but the column stays in focus (the scroll bar doesn't move). When the remoteSort is set to true, when I click on the column header, the scroll bar moves all the way to the left to its initial position.

    Hope I make any sense, any help is appreciated on this issue.

    Here is the code:

    Code:
    var NeList = function(){
        var neStore = new Ext.data.JsonStore({
            root: 'nes',
            remoteSort: true,
            totalProperty: 'totalCount',
            fields: [{name:'id'},{name: 'icon'}, {name: 'name'}, {name: 'severity'}, {name: 'type'}],
            url: 'neList.json'
        });
            
        var listToolbar = new Ext.PagingToolbar({
            pageSize: 25,
            store: neStore,
            displayInfo: false
        });    
            
        this.loadData = function () {
            neStore.load();    
        }
            
        NeList.superclass.constructor.call(this,{
            title: 'Ne List',
            store: neStore,
            width:200,
            height:300,
            renderTo: document.body,
            cm: new Ext.grid.ColumnModel([{
                header: 'Name',
                sortable: true,
                dataIndex: 'name'
            }, {
                header: 'Severity',
                sortable: true,
                dataIndex: 'severity'
            }, {
                header: 'Type',
                sortable: true,
                dataIndex: 'type'
            }]),
            stripeRows: true,
            bbar:listToolbar
        });    
    };
    
    Ext.extend(NeList, Ext.grid.GridPanel);
    
    
    Ext.onReady(function(){
        var grid = new NeList();
        grid.loadData();
    });
    Here is the JSON file
    Code:
    {
        nes:[
            {id:1,name:'Site 001',severity:'Critical',type:'Site'},
            {id:2,name:'Site 002',severity:'Critical',type:'Site'},
            {id:3,name:'Site 003',severity:'Major',type:'Site'},
            {id:4,name:'Site 004',severity:'OK',type:'Site'},
            {id:5,name:'Site 005',severity:'OK',type:'Site'},
            {id:6,name:'Site 006',severity:'OK',type:'Site'},
            {id:7,name:'Site 007',severity:'OK',type:'Site'}
        ],
        totalCount: 7
    }

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Can you check if your problem is the same with 2.2.1 before we go further?

    http://extjs.com/forum/showthread.ph...547#post282547

  3. #3
    Ext User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    madamut is on a distinguished road

      0  

    Default


    I just checked with 2.2.1 and the problem is still there.

  4. #4
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    definitely smells of one of the solutions in the Grid FAQ and/or one of the bug reports. I'd search both.

  5. #5
    Ext User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    madamut is on a distinguished road

      0  

    Default


    I checked the Grid FAQ already, I also searched the forums with the search box from the left top corner, I assume the bug reports get searched too. Maybe I should have posted in the BUG forum ...

    Is there a way I can move the thread to Ext: Bugs?

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    YOu need to be a moderator to move the thread I believe. Bugs are hard to search for. I'm pretty sure there are some threads on this already. I'd bet money that Condor has posted a solution.

  7. #7
    Ext User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    madamut is on a distinguished road

      0  

    Default


    Any suggestion on this one?
    Should I create a thread in the Bugs forum, or maybe somebody can move it there?

  8. #8
    Ext User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    madamut is on a distinguished road

      0  

    Default


    I just noticed somebody moved it to the bugs forum, thanks

  9. #9
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,833
    Vote Rating
    609
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    The reason this occurs is because when using local sorting, you're guaranteed to have the same data, just in a different order. However when you're using remote sorting, the data returned could be different. As such, on the load event, the grid is scrolled to the top. In your case, if you're sure you'll be returning the same data it would be pretty simple to override, by saving the scroll position before the sort event. As such, I'll mark this one as closed.

    Thanks for the detailed report, however.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  10. #10
    Ext User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    madamut is on a distinguished road

      0  

    Default


    Thanks for the hints evant,

    In case anybody else needs this, here is what I've done:

    1. Extend the GridView class so that when the header is clicked the scroll position is saved, then on load restore the scroll position.

    Code:
    /**
     * Avoid movement of scroll position due to resort with remoteSort set to true
     */
    var SavedScrollPosGridView = Ext.extend(Ext.grid.GridView, {
        onHeaderClick: function (g,index) {
            this.sortRequest = true;
            this.sortScrollState = this.getScrollState();
            SavedScrollPosGridView.superclass.onHeaderClick.apply(this,[g,index]);
        },
        onLoad: function() {
            if(this.sortRequest) {
                this.restoreScroll(this.sortScrollState);
                this.sortRequest = false;
            } else {
                SavedScrollPosGridView.superclass.onLoad.apply(this);    
            }
        }
    });
    2. When creating the GridPanel, supply my version of GridView like so:

    Code:
    ...
    store: neStore,
    width:200,
    height:300,
    view: new SavedScrollPosGridView(),
    renderTo: document.body,
    ...

Thread Participants: 2

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