updateData(connectionParameters: Object, options: Object)
[starting from version: 2.3]
Helps to update data for the report without cleaning the report. Only the dataSource
is updated, whereas the slice, all defined options, number and conditional formatting, the scroll position stay the same. For all data sources, updateData
allows connecting to a new data source. For JSON data source it is also possible to update only some part of the data.
Parameters
connectionParameters
– Object. It contains connection parameters. The connectionParameters
object has the same structure as the Data Source Object. options
(optional) – Object. Contains additional options: partial
(optional) – Boolean. For JSON data source only. Allows partial updating of the data. When partial
is set to true
, you can add, update, or remove certain records of JSON array. For more information, check example number 4. Default value: false
.ignoreSorting
(optional) – Boolean. Set ignoreSorting: true
and current sorting defined in the report will be ignored when you update the data. Default value: false
.ignoreScroll
(optional) – Boolean. Set ignoreScroll: true
and current scroll position in the pivot table will be ignored when you update the data. Default value: false
. Examples
1) Update data from Microsoft Analysis Services:
flexmonster.updateData({ type: 'microsoft analysis services', proxyUrl: 'http://olap.flexmonster.com/olap/msmdpump.dll', dataSourceInfo: 'Provider=MSOLAP; Data Source=extranet;', catalog: 'Adventure Works DW Standard Edition', cube: 'Adventure Works' });
Open the example on JSFiddle.
2) Update data from CSV data source:
flexmonster.updateData({ type: 'csv', filename: 'data.csv' });
Try on JSFiddle.
3) Update data from JSON inline data:
var jsonData = [{
"Color": { "type": "string" },
"M": {
"type": "month",
"dimensionUniqueName": "Days",
"dimensionCaption": "Days",
"caption": "Month"
},
"W": {
"type": "weekday",
"dimensionUniqueName": "Days",
"dimensionCaption": "Days",
"caption": "Week Day"
},
"Country": {
"type": "string",
"hierarchy": "Geography"
},
"State": {
"type": "string",
"hierarchy": "Geography",
"parent": "Country"
},
"City": {
"type": "string",
"hierarchy": "Geography",
"parent": "State"
},
"Price": { "type": "number" },
"Quantity": { "type": "number" }
},
{
"Color": "green",
"M": "September",
"W": "Wed",
"Country": "Canada",
"State": "Ontario",
"City": "Toronto",
"Price": 174,
"Quantity": 22
}];
flexmonster.updateData({ data: jsonData });
Check out on JSFiddle.
4) How to use updateData
for adding/updating/removing partial data:
First of all, we add id
and delete
types to the first object of JSON array:
{ "Category": { "type": "string" }, "Price": { "type": "number" }, "RowId": { "type": "id" }, "DeleteRow": { "type": "delete" } }
Then, when defining the data, we specify an id
field for every object the following way:
{ "Category": "Accessories", "Price": 242, "RowId": 1 }
To add or update only some of the records use partial: true
:
var dataForUpdate = [{ "Category": "Cars", "Price": 51844, "RowId": 4 }] flexmonster.updateData({data: dataForUpdate}, {partial: true});
To delete the records specify id
and delete
fields:
var dataForUpdate = [{ "RowId": 3, "DeleteRow": true }] flexmonster.updateData({data: dataForUpdate}, {partial: true});
See also