Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Sorting in a Grid

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    St. Helens, England
    Posts
    30

    Default Sorting in a Grid

    Hi all,

    I'm having a problem with the sorting on grids I am building. I have looked extensively around the forum but can't see anything pertaining to the problem I am having.

    Basically, when I go to sort the grid by clicking on the headers it will only sort them in ASC order regardless of how many times I click. However, if I click on the little arrows and select sort desending/ascending from the menu that appears it works fine.

    The column model is as follows:

    Code:
    cmEnquiries = new Ext.grid.ColumnModel([
        {header: "Enquiry #",    dataIndex: "enquiry_number", width: 100},
        {header: "Client",        dataIndex: "client_id",    width: 100,    renderer: lookupClientName,    sortType: lookupClientName}, 
        {header: "Ship Name",    dataIndex: "ship", id: 'enquiry-grid-ship' },
        {header: "IMO Number",    dataIndex: "imo_number" },
        {header: "Status",        dataIndex: "status", renderer: lookupStatus, width: 150}
    ]);
    cmEnquiries.defaultSortable = true;
    The store itself has a default sorting as follows:

    Code:
    thisStore.setDefaultSort('enquiry_id', 'ASC');
    The rest of the code is standard grid stuff, does anyone have any idea what might be causing this to happen? Thanks

    Edit: A point of note as well is that the request to the server always contains ASC as the sort so it definitely isn't a case of the server not sorting it.
    Last edited by SSJSparky; 11 Apr 2008 at 7:04 AM. Reason: adding fact that ASC is always in request

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    are you seeing the sort parameter change in the request to your server?

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    St. Helens, England
    Posts
    30

    Default

    Nope, using firebug I can see that the sort remains ASC for each request made (unless I use the submenus that appear when you click the arrow to explicitly select ascending or descending)

  4. #4
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    What if you remove
    PHP Code:
    thisStore.setDefaultSort('enquiry_id''ASC'); 

  5. #5
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    St. Helens, England
    Posts
    30

    Default

    Doing so removes the default sorting but still has no effect on the sorting behaviour of the grid. This really has me stumped!

  6. #6
    Sencha User
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    583

    Default

    Hi there,
    I don't see any problem in your code, but if you create a complete example, I mean with data etc, someone could help you...

  7. #7
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    What does the bigger picture look like? That is, what does your html head section look like, etc.? Came across a few threads recently where people were doing something funky they indavertently didn't mention/notice.

    Other than that, post your complete code, maybe you think something is 'standard' but it isn't.


    Other thought would be to go here and add listeners. See what the sort change listener etc has to tell you.

  8. #8

    Default

    I'm working with Sparky on this, thought I should mention that this uses a jsonstore using a default config jsonreader because we're returning metadata (to avoid having hardcoded record definitions), and that this uses an override kindly provided by Condor in http://extjs.com/forum/showthread.php?t=27835 (and is now in the SVN).

    edit: PS - the little arrow in the header bar never moves from the default sort column, nor flips over, even when the grid is successfully sorted by other columns.

  9. #9
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    St. Helens, England
    Posts
    30

    Default

    When I remove "remoteSort: true" from the config the sorting works and the arrow appears in the appropriate header box as per normal, as soon as I add remoteSort: true into the config again the arrow to indicate the sorting refuses to appear and sorting is always in ASC order.

    I know that remoteSort requires the sorting to be performed on the server side and this is definitely not the problem, it is simply that the grid seems to always post ASC as the sort order and does not display the arrow icon when remoteSort: true is set.

  10. #10
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    Did you ever try adding the listeners?

Page 1 of 2 12 LastLast

Posting Permissions

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