Results 1 to 5 of 5

Thread: grid column sorting causing multiple server hits

  1. #1

    Default grid column sorting causing multiple server hits

    I have a grid setup with column sorting and remoteSort:true set in the store (jsonReader). Each time I click on a column header to change the sorting, it makes 3 identical xhr calls.
    Any ideas what I would check or debug? The code is too lengthy to post here, but I will post specific portions if needed.
    It has no impact on the operation of my app, but obviously it could have a performance impact on the server.

  2. #2
    Sencha User VinylFox's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,501

    Default

    Posting a bit of your code would help.

    Typically, this happens when your unknowingly adding a listener multiple times. I had this happen to me a while ago. At least I think thats what it was for me when this happened...Ill probably be able to spot it in your code.

  3. #3

    Default

    Hi, this post seems old but I have elements that may help someone to answer (yes, I'm facing the same problem in Ext-1.1.1).

    In fact I have one grid on a page, which is ajax-injected into a div. Depending on the user choice, different grids may be injected. For ex., I may inject a Runway grid, then, onClick, replace it by another Airport grid. To allow my scripts to be generic, all grids have the same name (resultGrid).

    Code:
    Ext.get("searchResults").load ({
        url: "/test/" + grid + "_grid.js",
        scripts:true,
        callback: function() {
            resultGrid.init();
            resultGrid.render();
        }
    });
    Each Grid is defined in a wrapper:
    Code:
    resultGrid = function() {
    
    var ds, cm, columns, grid, paging;
    
    return {
    
        init : function () {
    
                // create the Data Store
                    ...
                });
    
                cm = new Ext.grid.ColumnModel(columns);
    
                grid = new Ext.grid.Grid('searchResults', {
                    ...
                });
    
            }, //init
            destroy: function () {
                grid.purgeListeners();
                grid.destroy();
                ds=null;
                grid=null;
                cm.purgeListeners();
                cm=null;
            },
            render: function() {
                grid.render();
    
            },
            load: function(params) {
            },
            getGrid: function() {
                return grid;
            },
            getDataStore: function() {
                return ds;
            },
            getColumnModel: function() {
                return cm;
            },
    
        } // return
    
    }();
    The fact is: the 1st time the 1st grid is displayed, clicking on a header fires 1 server request. But when the 2d grid is injected (and replaces the 1st One), clicking on a header fires 2 server requests, and so on...

    Each time a new grid is loaded, I try to destroy the previous one:
    Code:
       grid.purgeListeners();
       grid.destroy();
       ds=null;
       grid=null;
       cm.purgeListeners();
       cm=null;
    But the problem remains.

    I think that event handlers on the header cells are not 'released' when the grid is destroyed.

    Anybody has an idea? Is there something wrong in the way we handle grids, or maybe there's a trick to unregister thoses listeners manually ?

    Thanks

  4. #4
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    the grids gridView would need cleanup as well. That holds the events for column actions.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5

    Default

    I've also tried the following:

    Code:
    grid.events['headerclick'].clearListeners()
    without success.

    BUT, interestingly enough: I was using the ext-jquery adapter and using the native ext-base adapter solved the problem.

    In fact it turns out that somebody from our team has replaced the ext version of jQuery by a more recent one (1.2.1). Switching back to the original version solved the problem too.

    This problem may be very specific but hope it may help.

    Oh and thank Doug for trying to help me :-)

    Regards
    Last edited by StabiloBoss; 7 Feb 2008 at 1:22 PM. Reason: Forgot to thanks Doug

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •