JSFiddle - React, Tailwind, and code Playground
Events
by Flexmonster Pivot Table
January 27, 2025
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<p>
Notice that cells in the <code>Country</code> column cannot be edited because its <a target="_blank" href="https://www.flexmonster.com/api/field-mapping-object/#editing">editing</a> mapping property is set to <code>false</code>.
</p>
<div id="pivot-container">The component will appear here</div>
CSS
.output {
width: 80%;
height: 300px;
margin-left: auto;
margin-right: auto;
padding: 20px;
background: rgba(242, 242, 242, 1);
font-family: Menlo, Monaco, "Courier New", Courier, monospace;
white-space: pre-wrap;
font-size: 16px;
font-weight: 400;
overflow-y: scroll;
margin-top: 20px;
margin-bottom: 10px;
}
code {
font-size: 105%;
color: #DF3800;
background-color: #f5f5f5;
padding: 1px 4px;
font-family: monospace !important;
border-radius: 4px;
}
p {
font-size: 15px;
line-height: 1.5;
padding-right: 10px;
padding-left: 10px;
}
a {
color: #00a45a;
text-decoration: none;
}
JavaScript
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
height: 340,
report: {
dataSource: {
data: getData(),
mapping: {
"Color": {
type: "string"
},
"Country": {
type: "string",
editing: false
},
"RowId": {
type: "id"
},
"Price": {
type: "number"
}
}
},
options: {
grid: {
type: "flat"
},
editing: true
}
}
});
function getData() {
return [
{
"Color": "green",
"Country": "USA",
"RowId": 1,
"Price": 174
},
{
"Color": "red",
"Country": "Canada",
"RowId": 2,
"Price": 30
},
{
"Color": "blue",
"Country": "France",
"RowId": 3,
"Price": 283
},
{
"Color": "purple",
"Country": "Germany",
"RowId": 4,
"Price": 371
}
];
}