API call openCalculatedValueEditor

Calculated measures

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<button onclick="openCalculatedValueEditor()">Open Calculated Value Editor</button>
<button onclick="openSpecifiedCalculatedValueEditor()">Open Calculated Value Editor For Revenue</button>
<button onclick="openSpecifiedCalculatedValueEditorWithCallback()">Open Calculated Value Editor With Callback</button>

<div id="pivot-container"></div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      type: "csv",
      filename: "data/data.csv"
    },
    slice: {
      rows: [{
        uniqueName: "Category"
      }],
      columns: [{
        uniqueName: "[Measures]"
      }],
      measures: [{
          uniqueName: "Price",
          aggregation: "sum"
        },
        {
          uniqueName: "Revenue",
          formula: "sum('Quantity') * sum('Price')",
          caption: "Revenue"
        }
      ]
    },
  }
});

function openCalculatedValueEditor() {
  pivot.openCalculatedValueEditor();
}

function openSpecifiedCalculatedValueEditor() {
  pivot.openCalculatedValueEditor("Revenue");
}

function openSpecifiedCalculatedValueEditorWithCallback() {
  pivot.openCalculatedValueEditor("Revenue", function(response) {
     console.log("Field: " + response.uniqueName + ", " + "was removed: " + response.isRemoved);
  });


}