1

I'm using JQGrid 4.4.0 and I would like to override the default behavior for how integers are sorted. I can achieve this by setting the sorttype property of each colModel to a function instead of the literal 'int'.

I'd like to know, though, is there a way that I can make this a global change to my JQGrid configuration, as the example here shows?

The Davester
  • 498
  • 3
  • 8

1 Answers1

2

What you can do is to use template property of colModel or the usage of cmTemplate option of jqGrid to define default sorttype property for all columns of the grid. If you would set cmTemplate option in $.jgrid.defaults you will change the default sorttype property for all columns of all grids:

$.extend($.jgrid.defaults, {
    cmTemplate: {
        sorttype: 'int' // you can use functions in the same way
                        // to define custom sorting
                        // see https://stackoverflow.com/a/5296935/315935
                        // for the code example
    }
});

Look at the answer for more details. For example if you want to define custom sorting like function from the answer

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • @TheDavester: You are welcome! I recommend you to use `cmTemplate` and `template`. The options can reduce the code and make it more readable and better manageable. – Oleg Sep 13 '12 at 17:43