Working with Table Header Element

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example displays working with table header element. After starting the example the following operations are executed:

Partial element key is a set of pairs (<dimension-key>; <element key>) for the dimensions included into table header element.

Source Code

Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Data Analysis section):

// Get table top header
SPPLPivotTableHeader topPivotHeader = m_gridPivotTable->topHeader();
// Get table top header elements
SPPLPivotTableHeaderElements pivotTableHeaderElements = topPivotHeader->elements();
if (pivotTableHeaderElements->elementsCount() > 0) {
    // Get first element
    SPPLPivotTableHeaderElement element1 = pivotTableHeaderElements->getElementByIndex(0);
    printf("Obtained element index: %d\n", pivotTableHeaderElements->getIndexOfElement(element1));
    // Get dimensions linked to this element
    SNArray dimensions = element1->correspondingDimensionElements();
    printf("Number of dimensions linked to element: %d\n", dimensions->count());
    // Create a new element based on dimensions
    SPPLPivotTableHeaderElement element2 = PPLPivotTableHeaderElement::headerElement(dimensions);
    printf("Partial element key description: %s\n", element2->keyPart()->description()->UTF8String());
    // Generate dictionary with table header element settings
    SNMutableDictionary elementSettings = element2->generatePlist()->qClass<NMutableDictionary>();
    printf("Number of dictionary keys with table header element settings: %d\n", elementSettings->count());
    if (elementSettings->count()) {
        SNString key = elementSettings->allKeys()->objectAtIndex<NString>(0);
        SNString value = elementSettings->objectForKey<NString>(key);
        if (value != nil) {
            printf("Value of first dictionary pair with the %s key is equal to %s\n", key->UTF8String(), value->UTF8String());
            } else {
            printf("Value of first dictionary pair with the %s key is not defined\n", key->UTF8String());
        }
    }
}

After executing the example the development environment console displays index of the first table header element, the number of linked dimensions, its partial key description, the number of settings dictionary elements, and also value of the first element of this dictionary:

Obtained element index: 0

Number of dimensions linked to element: 1

Partial element key description: <NMutableDictionary:

<NNumber:533> => <NNumber:11>

>

Number of dictionary keys with table header element settings: 1

Value of first dictionary pair with the 533 key is not defined

See also:

Example of pplib++ Library Use