| Visual Basic (Declaration) | |
|---|---|
Public Interface ILayoutActions | |
| C# | |
|---|---|
public interface ILayoutActions | |
The layout (fields, filters, sorting, totals visibility, etc.) may be changed by a user manually (drag-and-drop, context menus, etc.) rather than through the ILayoutActions methods. The main advantage of the ILayoutActions methods over manual actions is that several actions can be performed as a single "undo" unit.
The general layout actions:
- Clear the layout. See
ClearLayout. - Swap axes. See
SwapAxes. - Change the marking type. See
SetMarkingType. - Change the layout title. See
SetViewTitle.
The field-related layout actions:
- Add a new field (append or insert). See
AppendField,InsertField. - Move an existing field. See
MoveField. - Remove an existing field. See
RemoveField.
The attribute-related (hierarchy-related) layout actions:
- Drill the hierarchy. See
DrillHierarchy. - Hide the level. See
HideLevel. - Change the totals visibility. See
DisplayTotals,HideTotals. - Change the sorting order. See
SetSortOrder,RemoveSortOrder.
The filters-related layout actions:
- Apply the member filter. See
ExcludeMembers,KeepOnlyMembers,DrillMembers. - Set the range/value/heading/topN filter. See
SetFilter. - Clear the filter. See
RemoveFilter.
Most of the methods that modify an instance of the class (that implements ILayoutActions) return a reference to that same instance. Since a reference to the instance is returned, you can call a method or property on the reference. This can be convenient if you want to write a single statement that chains successive operations one after another.
| C# | Copy Code |
|---|---|
// get the schema SchemaDefinition schema = pivotView.DataSource.Schema; // initialize new undo/redo unit with name 'Initialization' using (ILayoutActions la = pivotView.BeginLayoutUpdate("Initialization")) { // get from schema the hierarchy with the unique name '[Order Date].[Order Date]' Hierarchy orderDate = schema.Get<Hierarchy>("[Order Date].[Order Date]"); // set marking type to the Circle la.SetMarkingType(MarkingType.Circle); // append the hierarchy 'orderDate' to the Column la.AppendField(orderDate.UniqueName, ShelfKind.ColumnShelf); // append the measure '[Measures].[Total Product Cost]' right after the hierarchy la.AppendField("[Measures].[Total Product Cost]", ShelfKind.ColumnShelf); // appent the attribute '[Customers].[Customer Country]' to the Row la.AppendField("[Customers].[Customer Country]", ShelfKind.RowShelf); // appent the measure '[Measures].[Order count]' to the Color la.AppendField("[Measures].[Order count]", ShelfKind.ColorShelf); // drill down to the 1st level of the hierarchy (note: hierarchy levels are zero based) la.DrillHierarchy(orderDate.UniqueName, 1, ShelfKind.ColumnShelf); // drill down member 'Q2 1995' of the hierarchy la.DrillMembers(orderDate.UniqueName, 1, DrillDirection.Down, string.Format("[{0}].&[{1}]", orderDate.Levels[0].UniqueName, "1995.2")); // exclude from grid '1996' year la.ExcludeMembers(orderDate.Levels[0].UniqueName, string.Format("[{0}].&[{1}]", orderDate.Levels[0].UniqueName, "1996")); // commit undoable unit with name 'Initialization' la.Commit(); } // NOTE: la.Dispose() must reject our changes if la.Commit() or la.Reject() isn't called yet. | |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2