PivotTable column sort not working

Is it possibile to sort columns by a function or sort columns by a different field or to format the column header with a function? My case is a date column and I need it sorted as date but displayed in a user friendly format. I tried putting a function both in sort and columnsSort following an example in your code snippets, but it doesn't work:

const dateParse = webix.Date.strToDate("%d/%m/%Y");
...
structure: {
  rows: ["atleta"],
  columns: [
    {
      id: "data_allenamento",
      sort: function(a, b) {
        a = dateParse(a);
        b = dateParse(b);
        return a > b ? 1 : a < b ? -1 : 0;
      }
    }
  ]...
Tagged:

Comments

  • edited March 10

    Hello @lveronese,

    Is it possibile to sort columns by a function or sort columns by a different field or to format the column header with a function?

    Yes, it is indeed possible to apply a custom sorting function to certain columns within the pivot component. In order to do that, you will need to refer to the header content of the underlying datatable and set the sorting function explicitly for every column. Please take a look at the following example: https://snippet.webix.com/nosntg1b.

  • My problem is not about sorting the column contents but sorting the column headers. In my example I have a header for each date and need the headers to be sorted in date ascending order.

  • Hello @Iveronese,
    You can set the order of the columns with the help of the columnSort property.
    Please take a look at the following example:
    https://snippet.webix.com/vmmfktte

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!