Need a special offer?Find out if your project fits.
+
List of all demos

JavaScript Pivot Table: classic view

The classic form is a pivot table's view that gives an Excel-like layout of hierarchies. With the classic pivot table, you can show hierarchy sublevels next to one another, in separate rows or columns.


    const pivot = new Flexmonster({
      container: "#pivot-container",
      componentFolder: "https://cdn.flexmonster.com/",
      height: 450,
      report: {
        dataSource: {
          type: "csv",
          filename: "data/data.csv",
        },
        options: {
          grid: {
            type: "classic",
          },
        },
        slice: {
          rows: [
            {
              uniqueName: "Country",
            },
            {
              uniqueName: "Business Type",
            },
          ],
          columns: [
            {
              uniqueName: "Color",
            },
            {
              uniqueName: "[Measures]",
            },
          ],
          measures: [
            {
              uniqueName: "Price",
              format: "currency"
            },
          ],
          expandAll: true,
        },
       formats: [
          {
            name: "",
            thousandsSeparator: ",",
            decimalSeparator: ".",
            decimalPlaces: 2,
          },
          {
            name: "currency",
            currencySymbol: "$",
          },
        ],
      },
    });
    
    function changeLayout(layoutType) {
      pivot.setOptions({
        grid: {
          type: layoutType,
        },
      });
      pivot.refresh();
    }
    
    <button onclick="changeLayout('compact')">Use compact form</button>
    <button onclick="changeLayout('classic')">Use classic form</button>
    
    <div id="pivot-container"></div>
    

    By default, grand totals are displayed at the end of each row, and subtotals are placed in a separate row at the bottom.

    All the pivot table functionality works the same way: you can drag and drop, expand, collapse, drill down and up the hierarchies, sort and drill through values, and more. Just do it the way you got used to it in the older Excel versions.

    If multi-level hierarchies from your report contain a lot of sublevels, we recommend switching to the compact form which shows them more neatly.