Manage the Field List position

Options

by Flexmonster Pivot Table

HTML

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

<p>
  By default, the Field List is displayed in the pop-up window. You can change
  the Field List position using the
  <a
    target="_blank"
    href="https://www.flexmonster.com/api/options-object/#fieldlistposition"
  >fieldListPosition</a> option.
</p>

<button onclick="fieldListOnTheRight()">Field list on the right</button>
<button onclick="fieldListInPopUp()">Field list in the pop-up window</button>

<div id="pivot-container">The component will appear here</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: {
      filename: "data/data.csv",
    },
    slice: {
      rows: [
        {
          uniqueName: "Color",
        },
      ],
      columns: [
        {
          uniqueName: "[Measures]",
        },
      ],
      measures: [
        {
          uniqueName: "Price",
          format: "33gcyh6i",
        },
      ],
    },
    options: {
      configuratorActive: true,
    },
    formats: [
      {
        name: "33gcyh6i",
        currencySymbol: "$",
      },
    ],
  },
});

function fieldListOnTheRight() {
  pivot.closeFieldsList();
  const options = pivot.getOptions();
  options.fieldListPosition = "right";
  pivot.setOptions(options);
  pivot.on("aftergriddraw", () => {
    pivot.off("aftergriddraw");
    pivot.openFieldsList();
  });
  pivot.refresh();
}

function fieldListInPopUp() {
  pivot.closeFieldsList();
  const options = pivot.getOptions();
  options.fieldListPosition = "undefined";
  pivot.setOptions(options);
  pivot.on("aftergriddraw", () => {
    pivot.off("aftergriddraw");
    pivot.openFieldsList();
  });
  pivot.refresh();  
}