How to use updateData for adding/updating/removing partial data
Data source
by ilaria_nunziante
HTML
<link rel="stylesheet" href="https://cdn.flexmonster.com/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button id="btn" onclick="deleteRecord()">Update data: delete one record</button>
<div id="pivot-container"></div>
JavaScript
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
report: {
"dataSource": {
"type": "json",
"data": [
{
"RowId": "700652_37",
"CODE_2": "1150499",
"DG_4_1": 0.225806451612903,
"Week": "2017-W51"
},
{
"RowId": "700652_36",
"CODE_2": "1150499",
"DG_4_1": 0.225806451612903,
"Week": "2017-W50"
},
{
"RowId": "700652_37",
"CODE_2": "1150499",
"DG_4_1": 0.225806451612903,
"Week": "2017-W51"
},
{
"RowId": "700652_36",
"CODE_2": "1150499",
"DG_4_1": 0.225806451612903,
"Week": "2017-W50"
},
{
"RowId": "700652_36_2509_DG_4_1",
"CODE_2": "1150499",
"DG_4_1": 43.7741938626728,
"Week": "2017-W50"
},
{
"RowId": "700652_37_2509_DG_4_1",
"CODE_2": "1150499",
"DG_4_1": 43.7741938626728,
"Week": "2017-W51"
}
],
"mapping": {
"CODE_2": {
"type": "string",
"caption": "Product"
},
"DG_4_1": {
"type": "number",
"caption": "Forecasts-Pieces"
},
"Week": {
"type": "string",
"caption": "Week"
},
"DeleteRow": {
"type": "delete",
"caption": "DeleteRow"
},
"RowId": {
"type": "id",
"caption": "RowId"
}
}
},
"slice": {
"reportFilters": [
{
"uniqueName": "Week"
}
],
"rows": [
{
"uniqueName": "CODE_2"
}
],
"columns": [
{
"uniqueName": "[Measures]"
}
],
"measures": [
{
"uniqueName": "DG_4_1",
"aggregation": "sum"
}
]
}
}
});
function deleteRecord() {
var dataForUpdate = [
{
"RowId": "700652_37",
"CODE_2": "1150499",
"DG_4_1": 0.225806451612903,
"Week": "2017-W51",
},
{
"RowId": "700652_36",
"CODE_2": "1150499",
"DG_4_1": 0.225806451612903,
"Week": "2017-W50"
},
{
"DeleteRow": true,
"RowId": "700652_36_2509_DG_4_1",
"CODE_2": "1150499",
"DG_4_1": 43.7741938626728,
"Week":...