0

I have a extjs grid which has an email field, that has emails beginning with upper case and lower case. This field does not sort as it should.

Also, I have a date field of the format June 14, 2012 11:00 am.

I am not sure how to sort the date column ascending/descending as well.

I mean the the grid does sort data but it does not sort correctly

Here is my code:

var init_groupView = function() {
    userStore = new Ext.data.Store({
        url: 'scripts/users_getAllUsers.cgi',
        reader: new Ext.data.JsonReader({
            root: 'users',
            totalProperty: 'usersCount',
            id: 'user_id',
                 fields: [ 'fullname','email','login_time']
        })
});

Here is how my columns are sorted.

columns: [
            {header: "Full Name", width: 150, height:16, sortable: true, dataIndex: 'fullname'},
            {header: "E-Mail", width: 200, height:16, sortable: true, dataIndex: 'email'},
            {header: "Last Login", width: 150, height:16, sortable: true, dataIndex: 'login_time'}

]
Micheal
  • 2,272
  • 10
  • 49
  • 93
  • You have a typo in your code (missing the beginning quote on the 'fullname' property of your JsonReader), was that unintentional? Also missing the closing `}` on your `init_groupView` function. – Cᴏʀʏ Jul 17 '12 at 21:39
  • sorry. i didnt want display lot of data. so edited my code and copy pasted it. the code is working fine. Only issue is with the sorting the grid on emails and the dates, for which I feel i might have to add something more – Micheal Jul 17 '12 at 21:44
  • I would think that there would be some way to define the "type" on the column definitions, to give the grid a hint as to how to interpret the data. Otherwise it's probably sorting them all alphabetically after converting your data to strings. – Cᴏʀʏ Jul 17 '12 at 22:10

1 Answers1

0

You need to set the type on the field so it knows how to sort the values:

http://docs.sencha.com/ext-js/2-3/#!/api/Ext.data.Field-cfg-type

You'll probably also need to set the dateFormat config.

Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66