1. #1
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default Reset Client Side Sort

    Reset Client Side Sort


    Hi,

    I have a grid that I sort the data on the server side, then the user clicks on a column to sort the data on the client side. I have a clear button to reload the grid but the column the user clicked on to sort is sticking.

    How do I remove the state of the client side sort. I tried it with this:
    Code:
    Ext.state.Manager.getProvider().clear("searchgrid")  //searchgrid is the id of the grid component
    But no luck. Any ideas?

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    All your doing with that code is changing the cookie information. You probably need to clear the store's sortinfo in your reload process.

  3. #3
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    How can I clear the sort info?

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

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

      0  

    Default


    Maybe I'm not making myself clear enough. I initial load a grid via something like this:
    Code:
    Ext.getCmp("searchgrid").store.load(
    {
    url:'/data/search.request', 
    method:'post', 
    params: params			
    }
    );
    Then the user clicks on a column to sort on then. Then behind a button I reload the grid with:
    Code:
    Ext.getCmp("searchgrid").store.load(
    {
    url:'/data/search.request', 
    method:'post', 
    params: params			
    }
    );

    The column the user clicked on between the two grid loads is "sticking". I want to remove the client side sorting caused by the user.

    I tried:
    Code:
    Ext.getCmp("searchgrid").store.load(
    {
    url:'/data/search.request', 
    method:'post', 
    params: params			,
    sortInfo:''
    }
    );
    but no luck. Hopefully I explained myself. I would think it has something to do with the state manager but I could be wrong.

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    delete Ext.getCmp("searchgrid").store.sortInfo

  7. #7
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    Animal,

    I tried that both before and after the "load" statement. But the column the user clicked on "sticks". If I close down the browser and restart everything is ok.

    So it seems to be an issue with clearing the sort is not being propogated to the state mananger perhaps?

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    So the sort parameters "sort" and "dir" are passed to the server with the request for data?

  9. #9
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    actually no. I am sorting the data on my back-end via a SQL order by clause. As far as Ext is concerned the data is coming back unsorted. The user clicks on a column to sort it (client-side only), Im not using an remote sorting.

    When I reloda the grid it looks like the data is coming back to the grid in the original order but the column the user clicked on still is showing the sort indicator in the column.

    I think the issue is really just a visual issue, by not getting the column sort indicator removed. Based on the following thread: http://extjs.com/forum/showthread.ph...ght=clear+sort

    I came up with this:
    Code:
    viewHeaderHD = new  Ext.Element(Ext.getCmp("searchgrid").getView().mainWrap.dom.firstChild);
    viewHeaderHD.select('td').removeClass(Ext.getCmp("searchgrid").getView().sortClasses);
    				
    Ext.getCmp("searchgrid").store.load(
    {
    	url:FD.getContextRoot() + '/data/search.request', 
    	method:'post', 
    	params: params			
    }
    );
    		
    delete Ext.getCmp("searchgrid").store.sortInfo

Thread Participants: 2