sorting dgrid

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

sorting dgrid

Simon Walter
Hi everyone,

I am wondering what is the simplest/correct way to achieve this:

One field in a database table holds an integer which is a primary key in
another table (typical table relationship). When I display this table in
dgrid, I am doing something like:

                 field: 'airline',
                 label: 'Airline',
                 editor: Select,
                 editOn: 'click',
                 sortable: true,
                 editorArgs: {
                     options: selectAirline
                 renderCell: function(object, value, node, options){
                 // OR (I tried both)
                 get: function(item){
                     return selectAirlineval[item.airline];

This works fine and saves fine and all is well in dgrid land. However,
when I sort, it sorts by the integer stored in the database and thereby
also in the dstore. How can I override this behavior and have it sort by
the displayed value?

It would seem that I am "doing it wrong", but how would one then reverse
the above and have the data saved in the database correctly if the
dstore holds a text value rather than the primary key (int)?

I have read about overriding the sort function. This seems like a good
idea except that I always want to sort by what is displayed. It's not
some isolated case. The user expects what s/he sees to be sorted.

Question #2: Why are numbers sorted like strings? 100 comes before 11.
Anyway to "fix" that?

             field: 'id',
             id: 'id',
             label: 'ID',
             sortable: true,

Please tell me what I am doing wrong.


Dojo Toolkit:

[hidden email]
To unsubscribe, visit: