Configuring Which Columns to Display
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic explains how to configure which columns to display the IGGridView™ control based on externally provided custom logic.

Required background

The following table lists the topics prerequisite to understanding this topic.

Topic

Purpose

Adding the Grid Framework File

This topic explains how to add the grid framework file to the project.


In this topic


Introduction

Configuring column display summary

Use the IGGridViewColumnDefinition object to specify which and how columns are rendered. By default, the IGGridViewDataSourceHelper automatically generates and displays a column on the IGGridView for every public property existing in your underlying data object.

When using the IGGridViewDataSourceHelper, columns are automatically generated by default. Each public property existing in your underlying data object will display a column on the IGGridView. You can customize how, and which columns are displayed, by using the IGGridViewColumnDefinition object.

Standard column definitions support displaying any primitive data type capable of being converted into a string. Value column definitions support displaying any array of primitive data types capable of being converted into a string.

Image column definitions support image fields, which represent images with a string URL, NSURL, NSData object, or a UIImage object. The enumeration types for each of these different image representations follows:

  • IGGridViewImageColumnDefinitionPropertyTypeData
  • IGGridViewImageColumnDefinitionPropertyTypeImage
  • IGGridViewImageColumnDefinitionPropertyTypeStringUrl
  • IGGridViewImageColumnDefinitionPropertyTypeURL

Value column definitions support displaying any array of primitive data types capable of being converted into a string.

Ways to configure the column display

The following table details the two ways to customize which columns to display.

Configurable aspect

Details

Customize which columns to display

There are two ways to customize which columns to display.

  1. Adding strings to an array of fields that will be ignored. With each string mapping, to a property in the underlying data object.

    In Objective-C:

    [dataSource.fieldsToIgnore addObjectsFromArray:[NSArray arrayWithObjects:@"firstName", @"age", nil]];
    

    In C#:

    dataSource.FieldsToIgnore.AddObjects(new NSObject[]{new NSString("firstName") ,new NSString("Age")});
    
  2. Creating IGGridViewColumnDefinition objects, which tell IGGridView what kind of columns to display. Using IGGridViewColumnDefinition objects when the IGGridViewDataSource autoGenerateColumns property is set to YES. However, specified column definition display first without the column for that field being auto-generated.


Code Examples

Code examples summary

The following table lists the code examples included in this topic.

Example

Description

Standard Column Definition

Creation and usage of a standard column definition.

Image Column Definition

Creation and usage of an image column definition.

Value Column Definition

Creation and usage of a value column definition.



Standard Column Definition – Code Example

Description

The code below initializes an IGGridViewColumnDefinition for the lastName field

Code

In Objective-C:

IGGridViewColumnDefinition* col = [[IGGridViewColumnDefintion alloc]initWithKey:@"lastName"];
[dataSource.columnDefintions addObject:col];

In C#:

IGGridViewColumnDefinition col = new IGGridViewColumnDefinition("LastName");
dataSource.ColumnDefinitions.Add(col);

Image Column Definition – Code Example

Description

The code below initializes an IGGridViewImageColumnDefinition for a field named, thumb. This field contains a string URL from which the column retrieves the image onto the grid cell.

Code

In Objective-C:

IGGridViewImageColumnDefinition* thumbnail = [[IGGridViewImageColumnDefintion alloc]initWithKey:@"thumb" forPropertyType:IGGridViewImageColumnDefintionPropertyTypeStringUrl] ;
[dataSource.columnDefintions addObject:thumbnail];    

In C#:

IGGridViewImageColumnDefinition thumbnail = new IGGridViewImageColumnDefinition("thumb", IGGridViewImageColumnDefinitionPropertyType.IGGridViewImageColumnDefinitionPropertyTypeStringUrl);
dataSource.ColumnDefinitions.Add(thumbnail);

Value Column Definition – Code Example

Description

The following code illustrates how to use an array of strings to initialize an IGGridViewValueColumnDefinition into IGGridViewSingleFieldMultiColumnDataSourceHelper.

Code

In Objective-C:

NSArray  *names = [NSArray arrayWithObjects:@"Amy",@"Jim",@"Larry",nil];
IGGridViewValueColumnDefinition* col = [[IGGridViewValueColumnDefintion alloc]initWithKey:@"namesArray"];
IGGridViewSingleFieldMultiColumnDataSourceHelper* dataSource = [[IGGridViewSingleFieldMultiColumnDataSourceHelper alloc]initWithField:col];
dataSource.data = names;

In C#:

NSObject[] names = new NSObject[]{new NSString("Amy"), new NSString("Jim"), new NSString("Larry")};
IGGridViewValueColumnDefinition valCol = new IGGridViewValueColumnDefinition("namesArray");
IGGridViewSingleFieldMultiColumnDataSourceHelper dataSource = new IGGridViewSingleFieldMultiColumnDataSourceHelper(valCol);
dataSource.Data = names;

Related Content

Topics

The following topics provide additional information related to this topic.

Topic

Purpose

This topic provides basic information about creating an instance of the IGGridView™ and displaying data to help you get up and running with this control.

This section serves as an introduction to the IGGridView’s key features and functionalities.