Add a footer to Webix Pivot

Dear all,

I would like to develop a web app that will use your widget. In particular, it will use the “Webix Pivot” widget. I am trying to customize the widget, and one feature that I would like to add is to sum the values of each column. I tried to use a footer, but I did not succeed. Could you please instruct me on how to add this feature?

Thank you,
Vasilis

This will not directly solve your problem, but the export to excel feature can be used and then add totals to the spreadsheet.

Hello Vasilis,

You can access the grid view object inside the Pivot as

var grid = $$("pivot").$$("data");

And then define a footer for the needed column(s) for the grid:

grid.define("footer", true);
grid.config.columns[1].footer = { content:"summColumn" };
grid.config.columns[2].footer = { content:"summColumn" };
...
grid.refreshColumns();

It throws error

Uncaught TypeError: Cannot set property ‘footer’ of undefined

Uncaught TypeError: Cannot set property ‘footer’ of undefined

This code snippet should be called after data loading (when pivot has rendered the datatable with all its columns):

var grid = $$("pivot").$$("data");
grid.define("footer", true);
grid.attachEvent("onAfterLoad",function(){
   for(var i=1; i < grid.config.columns.length;i++){
 	  grid.config.columns[i].footer = { content:"summColumn" };
   }
   grid.refreshColumns();
});

Thank you. It’s worked now.

What about to add horizontal total column?

Hi,

Сould you provide more details ? Didn’t the footer solve the issue ?

Footer works fine. But also I want to see the total per year. I want to sum up horizontally.


By the way I couldn’t do sorting. I want to sort them in browser (not server)

Pivot creates columns only for data properties. But you can try to add columns to the end of the datatable and set values you need:

By the way I couldn’t do sorting.

Locally built-in sorting works correctly. Perhaps you could give some example ?