Undocumented Ext JS Grouping Sort Property

July 22, 2010 at 04:28 (extjs, javascript)

Background: Ext JS is an open source JavaScript library used for web design and geared towards interactive apps using technology such as Ajax. I am using version 3.2.1.

Today after an hour or two of frustration, I discovered an omission in the official online documentation of Ext JS. Under Ext.data.GroupingStore, the very useful property groupDir is mentioned nowhere, as of the time of this post. Without this property, it is exceedingly difficult (in my experience) to specify a simple sorting preference on the grouping field for this type of grid.

To illustrate, as of the time of this post there is irregular behaviour on the official Grids > Grouping example on the company website; clicking on the column header ‘Industry’ does not sort the data as one would expect. Instead, the grouping field is perpetually stuck in ascending mode. This is an example of dynamic sorting, but I was much more concerned with sorting statically while the grid first rendered. (I have not tried to get dynamic sorting to work.) Using the standard sortInfo: {field: ‘myField’, direction: ‘DESC’} did nothing. After several Google searches and much aggravation, I finally got the idea to look in the source of the class, particularly line 23888 of ext-all-debug.js, where I found that changing groupDir : ‘ASC’ to groupDir : ‘DESC’ produced the desired result, and that the property could be passed in through config.

Problem solved!

Advertisements

2 Comments

  1. sanantone said,

    Thanks a lot for this. You provided the solution to an annoying issued that’s been bugging me for weeks! The problem still exists in 3.3.0…

    • dansesacrale said,

      You’re welcome! Thanks for the feedback.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: