Working with Table Data View (Example 1)

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes some methods of working with a table data view. After starting the example the following operations are executed:

Source Code

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

// Delete all window subviews
NSArray *reportSubviews = [self.view subviews];
for(UIView *subView in reportSubviews)
{
    [subView removeFromSuperview];
}
// Create a report delegate
EAReportDelegateImpl *delegate = [[[EAReportDelegateImpl alloc] initWithOlapReport:m_olapReport] autorelease];
// Create a dashboard controller
MAExpressAnalysisReportViewController *report = [[[MAExpressAnalysisReportViewController alloc] initWithDelegate:delegate] autorelease];
// Create a table view controller object
MAGridDataViewController *gridController = [[MAGridDataViewController alloc] initWithDatasource:(GridDataViewDatasource *)delegate.gridDatasource];
// Determine whether table title is visible
gridController.isDataViewTitleVisible = NO;
// Set table data view controller delegate
gridController.delegate = report;
// Set additional custom data
gridController.tag = kViewModeTable;
// Create an array of controllers and add table data view controller to it
NSMutableArray *controllers = [NSMutableArray array];
[controllers addObject:gridController];
// Set array of report view controllers
report.dataViewControllers = controllers;
// Delete dimension container view in report
report.splitViewController.panelViewController = nil;
// Display report containing table
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:report];
[self.view addSubview: navController1.view];
// Determine whether there is table selection start area
[gridController setNoStartupSelection:NO];
if([gridController noStartupSelection] == NO)
{
    // Create and fill array of column indexes
    NSMutableArray *columns = [[NSMutableArray alloc] init];
    NSNumber *number = [NSNumber numberWithInt: 1];
    [columns addObject: number];
    NSNumber *number1 = [NSNumber numberWithInt: 2];
    [columns addObject: number1];
    // Create and fill array of row indexes
    NSMutableArray *rows = [[NSMutableArray alloc] init];
    NSNumber *number2 = [NSNumber numberWithInt: 1];
    [rows addObject: number2];
    NSNumber *number3 = [NSNumber numberWithInt: 2];
    [rows addObject: number3];
    // Create a cell selection area
    MAGridDataViewControllerSelection *selection = [MAGridDataViewControllerSelection selectionWithColumns:columns rows:rows type:@"" deductHeaderIndex: NO];
    // Set cell selection start area in table data view
    [gridController setStartupSelection:selection];
}
// Set specified row height
[gridController setHeight:100 toRow: 1];
// Set specified column width
[gridController setWidth:200 toColumn: 1];
// Refresh table data view data source
[[gridController gridDatasource] updateAsync];

After executing the example the mobile device screen displays the table, for which cell selection is set, and also height and width of the specified rows and columns are changed:

Then replace the code string:

MAGridDataViewController *gridController = [[MAGridDataViewController alloc] initWithDatasource:(GridDataViewDatasource *)delegate.gridDatasource];

is replaced with the following string:

MAGridDataViewController *gridController = [[MAGridDataViewController alloc] initWithDatasource:(GridDataViewDatasource *)delegate.gridDatasource themeUid:ttpsRed];

After executing the updated example the mobile device screen displays the table with changed color scheme:

See also:

Examples of Component Use