Columns order of WebDataRocks pivot grid

299 Views Asked by At

Trying to build a grid with months as columns using webdatarocks, and the problem is that columns are sorted alphabetically (Apr 2020, Aug 2020, Dec 200, ...). Is there an option to order columns by date (Dec 200, Nov 2020, Oct 2020, ...)?

Example is available here https://codesandbox.io/s/nifty-stonebraker-7mf56?file=/src/App.tsx

1

There are 1 best solutions below

0
On

This is possible by adding an object to your data that will define data types. Here is an explanation.

In your case, this object would look this way:

{
  "CONTRACT": {
    "type": "string"
  },
  "value": {
    "type": "number"
  },
  "date": {
    "type": "date string"
  },
  "name": {
    "type": "string"
  }
}, {
  type: "CONTRACT",
  value: 217,
  date: "Dec 2020",
  name: "24"
}, {
  type: "CONTRACT",
  value: 725.84,
  date: "Dec 2020",
  name: "3 "
}, ...

After this, the columns should be ordered by dates. Note that input dates should be formatted properly (compliant with ISO 8601).

The way dates are shown inside WebDataRocks can be modified with the help of datePattern from options.