var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
"dataSource": {
"type": "api",
"url": "https://olap.flexmonster.com:9500",
"index": "fm-product-sales"
},
slice: {
rows: [{
uniqueName: "Country"
}, {
uniqueName: "Category"
}, {
uniqueName: "[Measures]"
}],
columns: [{
uniqueName: "Color"
}],
measures: [{
uniqueName: "Price"
}, {
uniqueName: "Quantity"
}],
},
options: {
configuratorActive: false
}
},
width: "100%",
height: 600,
filteropen: onFilterOpen
});
var currentHierarchy = null;
function onFilterOpen(event) {
let element = document.querySelector(".fm-filter-view");
if (element) {
element.remove();
}
currentHierarchy = event.hierarchy;
$("#custom-filter").show();
$("#custom-filter .modal-title").text(event.hierarchy.caption);
let rows = pivot.getRows();
let columns = pivot.getColumns();
let reportFilters = pivot.getReportFilters();
let slice = {
rows,
columns,
reportFilters
};
$("#custom-filter .modal-body").html("");
loadMembers(event.hierarchy.uniqueName, slice);
}
function loadMembers(hierarchy, slice) {
// please send a post request with
// the hierarchy name and slice and
// return the members of the hierarchy that have values
// for the other hierarchies of the slice
let myData = {};
myData.hierarchy = hierarchy;
myData.slice = slice;
$.ajax({
type: "POST",
url: '/echo/json/',
data: myData,
dataType: "json",
success: function(data) {
// pass loaded members that matches your criteria to render in filter
// onGetMembers(data);
},
error: function(err) {
console.error(err);
}
});
// for demo purposes, here we pass all members that was loaded from Flexmonster
// it can be removed after...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.