Delete data bug
-click on 'Add New Data' (works fine: new data is added under 'green-USA')
-click on 'Remove Data' (works fine: data under 'green-USA' are removed)
-then click on 'Add Formula' (works fine: a new measure is added in the report)
-click again on 'Add New Data' (works fine: new data is added under 'green-USA' and the formula is correctly computed)
-click again on 'Remove Data' -> data are not removed.
by ilaria_nunziante
February 06, 2020
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<button id="addNewData">
Add new data
</button>
<button id="removeAddedData">
Remove added data
</button>
<button id="addFormula">
Add formula
</button>
<div id="pivot-container"></div>
JavaScript
$("#addNewData").click(function(e) {
flexmonster.updateData({
data: [{
"Color": "green",
"Country": "USA",
"Price": 555,
"Quantity": 26,
"RowId": 4
}]
}, {
partial: true
});
});
$("#removeAddedData").click(function(e) {
flexmonster.updateData({
data: [{
"Color": "green",
"Country": "USA",
"Price": 0,
"Quantity": 0,
"RowId": 4,
"DeleteRow": true
}]
}, {
partial: true
});
});
$("#addFormula").click(function(e) {
var formula = {
formula: 'sum("Quantity")*sum("Price")',
uniqueName: "QuantityTimesPrice",
caption: "QuantityTimesPrice",
grandTotalCaption: "QuantityTimesPrice",
active: true
};
pivot.addCalculatedMeasure(formula);
});
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
toolbar: true,
report: {
dataSource: {
data: getData()
},
slice: {
rows: [{
uniqueName: "Color"
},
{
uniqueName: "[Measures]"
},
],
columns: [{
uniqueName: "Country"
}],
measures: [{
uniqueName: "Price",
aggregation: "sum"
},
{
uniqueName: "Quantity",
aggregation: "sum"
}
]
}
}
});
function getData() {
return [{
"Color": {
"type": "string"
},
"Country": {
"type": "string"
},
"Price": {
"type": "number"
},
"Quantity": {
"type": "number"
},
"RowId": {
"type": "id"
},
"DeleteRow": {
"type": "delete"
}
}, {
"Color": "green",
"Country": "Canada",
"Price": 174,
"Quantity": 22,
"RowId": 1
}, {
"Color": "red",
"Country": "USA",
"Price": 1664,
"Quantity": 19,
"RowId": 2
}, {
"Color": "red",
"Country": "Canada",
"Price": 1190,
"Quantity": 292,
"RowId":...