Pivot sorting not working

Hi there guys!
I’ve tried an example from your docs page and it doesn’t seem to work for me:
https://docs.webix.com/pivot__configuration.html#sortingdatainpivottable

Check here:
https://snippet.webix.com/043ioux9
Data doesn’t seem to be sorted and when I switch between ‘asc’ and ‘desc’ nothing changes. Am I using it incorrectly?
Thanks!

Hello @vitaliy_kretsul

My apologies for misguiding you - this property does not exist for a long time (the feature was not applicable for complex use-cases).
We will correct the docs ASAP.

It is possible to set the default sorting with the data scheme in inner datatable. Please, check the following example:

https://snippet.webix.com/5ie5vq08

But as name is the only constant property in the calculated data, other fields can be used for initial sorting with the following event handler:

https://snippet.webix.com/kgv90xrt

Many thanks @Listopad
This clarifies everything.
One more thing:
User can sort any column by clicking on it’s header. What is the best way to preserve those sorting?
Thanks

@Listopad
I mean for example user clicks on some column’s header to sort that column. I want to save this somehow and when user comes next time - I will load it and show same column sorted. For this I need to be able to get current sorting state. Any ideas?

@vitaliy_kretsul

Please, check the following example:

https://snippet.webix.com/9m91bgbb

This could be achieved with set/getState API of the inner table. But please note that by default, IDs of the aggregated data are unique (timestamp-based), while restoring the state assumes a consistent structure of the grid (column and data IDs);

To be able to fully apply the previous state after reloading, the following settings are required:

  • stableRowId : true should be set in Pivot configuration (IDs of aggregated data will be based on the current structure),
  • Pivot structure should be saved as well as related state,
  • Raw data should not be changed since the state is saved (changes would affect the column IDs).

As an option, you can restore a partial data state:

var state = webix.storage.local.get("state");
pivot.$$("data").setState({ 
     open:state.open,
     sort:state.sort 
});