'Ordering groups individual after renaming

My product table is sorted with initialSort by the product release month ascending. I also grouped my products by a codename which is determinate by the ajax json response url and renamed them to readable names with a groupBy function. Now I want to sort my groups individual without loosing the month sorting in my groups. How is that possible?

var table = new Tabulator("#tableid", {
  ajaxURL: url,
  layout: "fitColumns",
  groupBy: "codename",
  groupBy:function(data){
    if (data.codename == "X123") {
      return "Productname for X123";
    }
    if (data.codename == "X124") {
      return "Productname for X124";
    }
    …
    …
  },
  initialSort:[
      {column:"month", dir:"asc"}
  ],  
  columns: [
    { title: "Product", field: "codename"},
    { title: "Month", field: "month"},
    …
    …
    …
  ]
});


Solution 1:[1]

Not exactly sure what you mean by "sort my groups individual", but is this what you're looking for ?

https://jsfiddle.net/r3f7pysw/

initialSort:[
      {column:"month", dir:"asc"},
      {column:"codename", dir:"asc"}
  ],

NOTE(1) : I dont think you want to return that string for your grouping, when it seems like its just the header Display string, and you're still going to be sorting on "codename" (becoz the string is the same with a change at the end, which really takes a "little" long to compare each time). But maybe you do...

NOTE(2) : Adding the seconds initialSort is like Ctrl-Click on the sorting to sort by multiple criteria. So if you single click on say, Month, remember that destroys the currentSort array and sets it just to Month.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael O'Keefe