DevExtreme Vue - PivotGridDataSource Methods
collapseAll(id)
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- pivotGridDataSource.collapseAll('Region');
- },
- // ...
- }
- </script>
See Also
- expandAll(id)
- fields[].expanded
collapseHeaderItem(area, path)
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- // Collapses the second quarter of 2015 in the column area
- pivotGridDataSource.collapseHeaderItem('column', [2015, 2]);
- },
- // ...
- }
- </script>
See Also
- expandHeaderItem(area, path)
- fields[].expanded
createDrillDownDataSource(options)
Provides access to the facts that were used to calculate a specific summary value.
Name | Type | Description |
---|---|---|
columnPath |
A path to the cell with the summary value by columns. |
|
customColumns |
The field names to be included for each fact. |
|
dataIndex |
The index of the measure for which the summary value is calculated. |
|
maxRowCount |
Maximum number of facts to get. |
|
rowPath |
A path to the cell with the summary value by rows. |
Data in the drill-down data source is paginated by default. Only the items on the first page are loaded when you call the load() method. To get all the items, turn the pagination off:
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- this.drillDownDataSource = pivotGridDataSource.createDrillDownDataSource({
- // Options are passed here
- });
- this.drillDownDataSource.paginate(false);
- this.drillDownDataSource.load()
- .then(
- (data) => { /* Process "data" here */ },
- (error) => { /* Handle the "error" here */ }
- )
- },
- // ...
- }
- </script>
See Also
dispose()
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- beforeDestroy() {
- pivotGridDataSource.dispose();
- },
- // ...
- }
- </script>
expandAll(id)
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- pivotGridDataSource.expandAll('Region');
- },
- // ...
- }
- </script>
See Also
- collapseAll(id)
- fields[].expanded
expandHeaderItem(area, path)
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- // Expands the second quarter of 2015 in the column area
- pivotGridDataSource.expandHeaderItem('column', [2015, 2]);
- },
- // ...
- }
- </script>
See Also
- collapseHeaderItem(area, path)
- fields[].expanded
field(id)
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // ...
- fields: [{
- caption: 'Sales',
- dataField: 'amount',
- summaryType: 'sum',
- area: 'data'
- }]
- });
- export default {
- mounted() {
- // The following commands return the same object
- pivotGridDataSource.field('Sales');
- pivotGridDataSource.field('amount');
- pivotGridDataSource.field(0);
- },
- // ...
- }
- </script>
See Also
field(id, options)
Call the load() method to update the PivotGrid:
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- // Changes the "Sales" field's summaryType
- pivotGridDataSource.field('Sales', { summaryType: 'avg' });
- pivotGridDataSource.load();
- },
- // ...
- }
- </script>
fields()
Gets all the fields including those generated automatically.
All options of all the fields.
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- this.pivotGridFields = pivotGridDataSource.fields();
- },
- // ...
- }
- </script>
See Also
fields(fields)
Specifies a new fields collection.
Call the load() method to update the PivotGrid:
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- pivotGridDataSource.fields([{
- dataField: 'region',
- area: 'row'
- }, {
- dataField: 'date',
- dataType: 'date',
- area: 'column'
- }, {
- dataField: 'sales',
- summaryType: 'sum',
- area: 'data'
- }]);
- pivotGridDataSource.load();
- },
- // ...
- }
- </script>
filter()
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // ...
- filter: ['age', '>', 18]
- });
- export default {
- mounted() {
- this.filterExpr = pivotGridDataSource.filter(); // returns ["age", ">", 18]
- },
- // ...
- }
- </script>
See Also
filter(filterExpr)
Call the reload() method to update the PivotGrid:
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- pivotGridDataSource.filter(['age', '>', 18]);
- // or
- // pivotGridDataSource.filter('age', '>', 18);
- pivotGridDataSource.reload();
- },
- // ...
- }
- </script>
See Also
getAreaFields(area, collectGroups)
The area that contains the fields to get.
Pass true to return grouped fields in a single array entry or false to return them as separate entries.
The default value is false.
All the options of all the fields within the area.
- <script>
- import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
- const pivotGridDataSource = new PivotGridDataSource({
- // PivotGridDataSource is configured here
- });
- export default {
- mounted() {
- this.columnAreaFields = pivotGridDataSource.getAreaFields('column', true);
- },
- // ...
- }
- </script>
See Also
getData()
Gets the loaded data. Another data portion is loaded every time a header item is expanded.
This method returns an object with the following structure:
- {
- rows: [{
- index: /* Row 1 index */,
- text: /* Row 1 caption */,
- value: /* Row 1 value */
- }, {
- index: /* Row 2 index */,
- text: /* Row 2 caption */,
- value: /* Row 2 value */,
- children: [{
- index: /* Row 2.1 index */,
- text: /* Row 2.1 caption */,
- value: /* Row 2.1 value */,
- children: [ /* Level 3 and deeper */ ]
- },
- // ...
- ]
- },
- // ...
- ],
- columns: [{
- index: /* Column 1 index */,
- text: /* Column 1 caption */,
- value: /* Column 1 value */
- }, {
- index: /* Column 2 index */,
- text: /* Column 2 caption */,
- value: /* Column 2 value */,
- children: [{
- index: /* Column 2.1 index */,
- text: /* Column 2.1 caption */,
- value: /* Column 2.1 value */,
- children: [ /* Level 3 and deeper */ ]
- },
- // ...
- ]
- },
- // ...
- ],
- values: [
- [
- [
- /* Measure 1 summary value 1 */,
- /* Measure 2 summary value 1 */,
- // ...
- ],
- [
- /* Measure 1 summary value 2 */,
- /* Measure 2 summary value 2 */,
- // ...
- ],
- // ...
- ],
- // ...
- ],
- grandTotalRowIndex: 0,
- grandTotalColumnIndex: 0
- }
The object mentioned above contains three arrays: rows
, columns
, and values
. Objects in the rows
and columns
arrays describe header items in the row and column areas and contain the following fields:
index
- the index of the row/column that contains the header item; used to find a summary value in thevalues
array;value
- the field value from the data source that corresponds to the header item;text
- the header item's caption;children
- an optional array that contains lower-level header items.
The values
array contains summary values. Each of them has three indexes. To get a summary value, use the following pattern:
- var value = values[/* row index */][/* column index */][/* measure index */];
You can pass grandTotalRowIndex
and grandTotalColumnIndex
as row index and column index to get grand total values.
If you use the XmlaStore and your data area is empty, this method returns the default measure values. They are hidden from the UI until you place the default measure in the data area using the field(id, options) method. The default measure is specified on the OLAP server.
- pivotGridDataSource.field(/* measure name */, { area: "data" });
See Also
load()
A Promise that is resolved after data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
<script> import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source'; const pivotGridDataSource = new PivotGridDataSource({ // PivotGridDataSource is configured here }); export default { mounted() { pivotGridDataSource.load() .then( (data) => { /* Process "data" here */ }, (error) => { /* Handle the "error" here */ } ); }, // ... } </script>
See Also
on(eventName, eventHandler)
Use this method to subscribe to one of the events listed in the Events section.
See Also
on(events)
Use this method to subscribe to several events with one method call. Available events are listed in the Events section.
See Also
reload()
Clears the loaded PivotGridDataSource data and calls the load() method.
A Promise that is resolved after data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
state()
Gets the current PivotGridDataSource state. Part of the PivotGrid UI component's state storing feature.
<script> import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source'; const pivotGridDataSource = new PivotGridDataSource({ // PivotGridDataSource is configured here }); export default { mounted() { // Get the state let pivotGridState = pivotGridDataSource.state(); // Set the state pivotGridDataSource.state(pivotGridState); // Reset to the default state pivotGridDataSource.state({}); // ===== or ===== pivotGridDataSource.state(null); }, // ... } </script>
state(state)
Sets the PivotGridDataSource state. Part of the PivotGrid UI component's state storing feature.
If you have technical questions, please create a support ticket in the DevExpress Support Center.