In order to create dhtmlxPivot on a page, you should initialize it. There are several main steps you need to take:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../../codebase/pivot.js"></script>
<link rel="stylesheet" href="../../codebase/pivot.css">
</head>
<body>
<div id="container"></div>
<script> var myPivot = new dhx.Pivot("container", {
fields: {
// initial pivot structure
},
fieldList: [
// the full list of fields
]
});
</script>
</body>
</html>
Related sample: Initialization
You have to include 2 code files for using dhtmlxPivot:
Check that you set right relative paths to these files:
<script type="text/javascript" src="codebase/pivot.js"></script>
<link rel="stylesheet" href="codebase/pivot.css">
Let's have a look at the structure of the dhtmlxPivot package to find out where to look for the files.
Next you need to add an HTML container to put a future Pivot component into:
<div id="container"></div>
To initialize dhtmlxPivot, you should use the dhx.Pivot
constructor. The constructor function takes two parameters:
var myPivot = new dhx.Pivot("container", {
data: dataset,
fields: {
rows: ["form", "name"],
columns: ["year"],
values: [{ id: "oil", method: "max" }, { id: "oil", method: "sum" }],
},
fieldList: [
{ id: "name", label: "name" },
{ id: "year", label: "year" },
{ id: "continent", label: "Continent" },
// more fields
]
}
);
It is also possible to skip setting a container for Pivot and to add it right into the document's body:
var myPivot = new dhx.Pivot(document.body, {
fields: {
// initial pivot structure
},
fieldList: [
// the full list of fields
]
});
The list of possible properties of the Pivot configuration object (the second parameter of the constructor):
Related sample: Initialization
Back to top