2

I am using a grid with loadOnce:true in order to have only one query to the server. The data is sorted on server side (multi-column sorting). Sorting is disabled on client side.

Before activating the grouping feature, navigation was working correctly.

By activating the grouping feature, the first page is OK. But when I go to the next page with the navigation button, the data is sorted on client-side according to the grouping column (even with groupDataSorted:true).

rowTotal: 10000,
gridview: true,
scroll: false, 
loadonce: true,

pgbuttons: true,
pginput: true,
rowNum: 100,
rowList: '',
datatype: 'json',
mtype: 'GET',

grouping: true,
groupingView : { 
      groupField : ['prodNo'],
      groupSummary: [true],
      groupColumnShow: [false],           
      groupText: ['({1})'],
      showSummaryOnHide: true,
      groupDataSorted : true,
      groupCollapse: false
    },
jsonReader: {root: 'list', userdata : 'list'},
url:'...'

My case is a bit special because I am sorting the data on server side according to a 'name' and 'date' columns, but grouping rows according to another 'prodNo' column. However I do not understand why the sorting is done on page navigation.

Is there a way to disable this client-side sorting on page navigation ?

thanks in advance

Samuel
  • 879
  • 10
  • 21

1 Answers1

4

If you use loadonce: true and the user click on the "Next Page" button the local data will be resorted by grindexes (it's the value of index property of the column which you use for grouping in groupField). So the easiest way to fix the problem in your case will be to implement custom sorting in the prodNo column.

You can try first to add to the definition of 'prodNo' column the custom sorting

sorttype: function () {
    return 1; // any constant value
}

The function sorttype will be called during sorting of local data. If it return the same results like in above example then all the data will be interpreted as the same and I hope that no additional sorting will be take place.

If the approach will not work because of some reason you can implement another sorting

sorttype: function (cellValus, rowData) {
    ...
}

For example if you want that local data will be sorted based on other columns 'name' and 'date' you can return from the sorttype in the 'prodNo' column the value like

sorttype: function (cellValus, rowData) {
    // probably the data need be converted in the sortable form yyyy-mm-dd
    return rowData.name + '_' + rowData.data;
}
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Adding the "sorttype: function () {return 1; }" as you suggested was enough to solve my problem. Merci! Thanks also for the explanation. – Samuel Jun 11 '12 at 10:50
  • 1
    Hey @Oleg `sorttype: function() { return 1; }` solved the issue of navigational sorting. But clicking on the heading of my date column is doing nothing. I tried with `sorttype:function (cellValue, rowData) { return cellValue}`.cellValue is a date which is in equal format as its in grid column. Doing this, sorting is happening but in weird order and it is also breaking navigational sorting. – Jaikrat Oct 16 '15 at 10:10
  • @Jaikrat: Sorry, but I can't help you without knowing what you do exactly. Which version and fork of jqGrid you use? Which format of input data you have? How the other properties of the column are defined and so on. It's better that you post *separate question* where you describe your problem. Correct usage of `sorttype` defined as function can help, but the wrong usage can create new problems. So one have to understand the problem to be able to solve it. – Oleg Oct 16 '15 at 10:32
  • or tried with `return $.datepicker.parseDate( 'm/d/yy', cellValue);` as well. – Jaikrat Oct 16 '15 at 10:36
  • @Jaikrat: I can repeat that I still have no idea what you do. If you want that somebody else help you then you should post separate question where you explains more detailed what you do. I posted some questions in my previous comment, but you didn't answer anyone. I'm not sure that `sorttype` defined as function is correct way in your case. One have to understand which data you load in the grid, how `colModel` is defined and how the data will be saved locally in jqGrid. Only after that one should understand why the standard sorting should work incorrectly and how to fix the problem. – Oleg Oct 16 '15 at 10:47