Version

OlapViewModel - Manipulating Data at Runtime

Topic Overview

Purpose

This topic provides a conceptual overview of how to manipulate data at runtime for those controls using the OlapViewModel.

OlapViewModel Limitations

Limitations

To record AddPivotItem action on the OlapViewModel , first you need to interact with one of the following four control areas :

  • Measures

  • Rows

  • Columns

  • Filters

Recording the AddPivotItem action is always from the xamPivotDataSelector even if adding the item to another control for instance, xamPivotGrid . Hence, you need to ensure that you click on any of the four areas mentioned above so that you are able to record AddPivotItem action.

OlapViewModel Recordable and Replayable Methods Summary

Methods summary chart

The following table briefly explains the recordable and replayable methods for testing the control. Additional information about each method is available following the table.

Legend:

record.png
– Record in UFT (default)
replay.png
– Replay in UFT (using script)
Method Action Description
record.png

Adds the pivot item from the xamPivotDataSelector ’s dimensions tree to the control’s target area.

replay.png

Obtains the pivot item (tree node) from its identifier and the target area from its name, and then adds the pivot item at the specified target index, to the target area.

If the target index is not specified, the item is added to the end of the target area’s existing collection.

record.png

Moves the pivot items in the control, for example, exchanging columns and rows.

replay.png

Obtains:

  • The source area using its name

  • The pivot item from the source via its identifier

  • The target area from its name.

Then moves the pivot item to the target area at the specified target index (if any). If the target index is not specified, the item is moved to the end of the existing target area collection.

record.png

Removes the pivot items from the control by dragging the item using the left mouse button and dropping outside of the item’s area or by closing them using the close button.

replay.png

Obtains the source area from its name, the pivot item from the source via its identifier and then removes the item.

record.png

Opens the pivot item’s filter dialog in the control’s source area.

replay.png

Obtains the source area from its name, the pivot item from the source via its identifier and then opens that item’s filter dialog.

record.png

Closes the pivot item’s filter dialog in the control’s source area.

replay.png

Obtains the source area from its name, the pivot item from the source via its identifier and then closes that item’s filter dialog.

AddPivotItem method

Description

Storing a pivot item’s identifier that is added (Tree node identifier), the target area name and the target index where the item is added.

Parameters

The following table explains the method’s parameters followed by code example.

Method parameter Description

oPivotItemId

Identifier of the IOlapViewModel’s pivot item. This can be the IOlapViewModel’s pivot item header caption, index, array of headers, and indices (Dimensions tree node).

oTargetPivotAreaName

Identifies the name of the IOlapViewModel’s target area where the pivot item needs to be added or moved.

iTargetIndex

Index of the IOlapViewModel’s target area where the pivot item needs to be added.

Example

The following example demonstrates how to add a tree node with header = “Child1” under the root node with header = “Root” to the target area with rows at target index of 1.

XamPivotGrid("xamPivotGrid1").AddPivotItem Array(“Root”, “Child1”), pvtRows, 1

The following example demonstrates how to add a child tree node at index 2 under the root node at index 0 to the target area with measures at target index of 0.

XamPivotGrid("xamPivotGrid1").AddPivotItem Array(0,2), pvtMeasures, 0

The following example demonstrates how to add a root tree node at index 2 to the target area with filters at target index of 2.

XamPivotGrid("xamPivotGrid1").AddPivotItem 2, pvtFilters, 2

The following example demonstrates how to add a root tree node with header=”Root2” to the target area with columns at the end of the existing collection.

XamPivotGrid("xamPivotGrid1").AddPivotItem “Root2”, pvtColumns

Possible exceptions

The following table lists the possible exceptions for the method and the reason that is likely to be causing them.

Exception name Possible reason

Incorrect item format

The pivot item ID is not of the correct format.

Item not found

Cannot find the pivot item (tree node).

Invalid target

The target area is not one of the valid options (Filters, Rows, Columns or Measures).

Invalid operation

Cannot add the pivot item to the specified target area since you can only add certain items to certain areas.

Index is out of range

The target index is out of range.

MovePivotItem method

Description

Storing the moved pivot item’s source area name and identifier, along with the target area name and the target index where the item is moved.

Parameters

The following table explains the method’s parameters followed by code example.

Method parameter Description

oSourcePivotAreaName

Identifies the IOlapViewModel source area’s name where the pivot item needs removing.

oPivotItemId

Identifies the IOlapViewModel’s pivot item. This can be the pivot item’s header caption or index within the IOlapViewModel source area.

oTargetPivotAreaName

Identifies the IOlapViewModel target area’s name where the pivot item needs inserting.

iTargetIndex

Index of the IOlapViewMode target area where the pivot item needs inserting.

Example

The following example shows how to move the, “Sales” pivot item from the source area (Columns) to target area (Rows) at a target index of 1.

XamPivotGrid("xamPivotGrid1").MovePivotItem  pvtColumns, “Sales”, pvtRows, 1

The following example shows how to move the, “Sales measures” pivot item from the source area (Measures) to target area (Measures) within the same area at a target index of 2.

XamPivotGrid("xamPivotGrid1").MovePivotItem  pvtMeasures, “Sales measures”, pvtMeasures, 2

The following example shows how to move the pivot item at index 3 from the source area (Rows) to target area (Filters) at a target index of 2.

XamPivotGrid("xamPivotGrid1").MovePivotItem  pvtRows, 3, pvtFilters, 2

Default setting

N/A

Possible exception

The following table lists the possible exceptions for the method and the reason that is likely to be causing them.

Exception name Possible reason

Incorrect item format

The pivot item ID is not of the correct format.

Item not found

Cannot find the pivot item (tree node).

Invalid target

The target area is not one of the valid options (Filters, Rows, Columns or Measures).

Invalid operation

Cannot add the pivot item to the specified target area since you can only add certain items to certain areas.

Index is out of range

The target index is out of range.

RemovePivotItem method

Description

Stores the pivot item, to be removed, source area’s name and identifier.

Parameters

The following table explains the method’s parameters followed by code example.

Method parameter Description

oSourcePivotAreaName

Identifies the IOlapViewModel source area’s name where the pivot item needs to be removed.

oPivotItemId

Identifies the IOlapViewModel’s pivot item. This can be the pivot item’s header caption or index within the IOlapViewModel’s source area.

Example

The following example demonstrates an action for removing the pivot item, “Sales” from the source area: Columns.

XamPivotGrid("xamPivotGrid1").RemovePivotItem  pvtColumns, “Sales”

Possible exceptions

The following table lists the possible exceptions for the method and the reason that is likely to be causing them.

Exception name Possible reason

Invalid option.

The source area is not one of the valid options (Filters, Rows, Columns or Measures).

Incorrect item format.

The pivot item ID is not of the correct format.

Item not found.

Cannot find the pivot item in the source area.

OpenFilterDialog method

Description

Stores the pivot item source area’s name and identifier whose filter dialog is opened or closed.

Parameters

The following table explains the method’s parameters followed by code example.

Method parameter Description

oSourcePivotAreaName

Identifies the IOlapViewModel source area’s name containing the pivot item whose filter dialog needs to be opened.

oPivotItemId

Identifies the IOlapViewModel’s pivot item. This can be the pivot item’s header caption or index within the IOlapViewModel’s source area.

Example

Demonstrates opening of the xamPivotDataSelector control’s, “Products” item in the “Columns” area filter dialog.

XamPivotDataSelector("dataSelector").OpenFilterDialog pvtColumns, "Product"

Possible exceptions

The following table lists the possible exceptions for the method and the reason that is likely to be causing them.

Exception name Possible reason

Invalid option.

The source area is not one of the valid options (Filters, Rows, Columns or Measures).

Incorrect item format.

The pivot item ID is not of the correct format.

Item not found.

Cannot find the pivot item in the source area.

Invalid operation.

The action is not valid if the pivot item does not contain a filter dialog.

CloseFilterDialog method

Description

Stores the pivot item source area’s name and identifier whose filter dialog is closed.

Parameters

The following table explains the method’s parameters followed by code example.

Method parameter Description

oSourcePivotAreaName

Identifies the IOlapViewModel source area’s name containing the pivot item whose filter dialog needs closing.

oPivotItemId

Identifies the IOlapViewModel’s pivot item. This can be the pivot item’s header caption or index within the IOlapViewModel’s source area.

Example

Demonstrates closing of the, “Products” item in the, “Columns” area filter dialog of the xamPivotDataSelector control.

XamPivotDataSelector("dataSelector").CloseFilterDialog pvtColumns, "Product"

Possible exceptions

The following table lists the possible exceptions for the method and the reason that is likely to be causing them.

Exception name Possible reason

Invalid option.

The source area is not one of the valid options (Filters, Rows, Columns or Measures).

Incorrect item format.

The pivot item ID is not of the correct format.

Item not found.

Cannot find the pivot item in the source area.

Invalid operation.

The action is not valid if the pivot item does not contain a filter dialog.

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic provides information about the testable user actions and elements of the controls that use OlapViewModel .

This topic provides reference information about the test object properties of the controls that use OlapViewModel .

This topic provides reference information about the common enumerations in the OlapViewModel proxy.