How to sort column data in alpha-numeric order in pivot?

604 views Asked by At

the following link generates a pivot jqgrid that will load some sales information about cars enter link description here

it has about 11 car sales objects. it has a custom sort order that i have given and the purpose of the custom sort order to display data in custom order when data loads to the grid and it works but the issue is when user clicks the column name 'model' it should be sorting car names by name in the alphabetical order but instead its sorts using my custom order. But it should not use custom order to sort columns when user clicks on the header, it should use its default sort order sorting by alphabetical order.

How do i still keep the custom order that i have given and at the same time let the columns gets sorted in the alphabetical order if user clicks a column?

secondly, Different browser shows different ways. when i load the grid with a large dataset it behaves differently in two of the following operations

In chrome: 1. When user selects 'All' (show all records) from the navbar at the bottom the custom order that i have given as the sort order for grid load breaks and some gets positioned in different places

but in IE browser, this won't happen

  1. In both IE and chrome, after loading data when user clicks the column name Model column data gets sorted using custom sort order and not by alphabetical order.

How do i fix these issues

1

There are 1 answers

0
Oleg On BEST ANSWER

You should just remove sorttype from the second (model) column if you want to sort the column by by alphabetical order. See https://jsfiddle.net/OlegKi/dk7uth40/3/

By the way free jqGrid support the option

threeStateSort: true

which implements 3-state sorting. You can see the results on the demo https://jsfiddle.net/OlegKi/dk7uth40/4/. The user sees the data in original order initially. By first click on the model column the data will be sorted in alphabetical order (in ascending order). By second click the data will be sorted in the descending alphabetical order. The third click on the column header will return the order in the initial sorting order.