Inserting and Deleting Columns
Send Feedback

Glossary Item Box

Topic Overview


This topic provides a conceptual overview, with code examples, of inserting and deleting columns on the IGGridView™ control.

Required background

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



Adding the IG Framework File

This topic explains the requirements for adding the grid framework file to an Xcode project, a requirement for using the IGGridView control.

In this topic


Inserting and deleting columns summary

For the purposes of this discussion, the IGGridView control recognizes two distinct and different column types, normal and fixed. A normal column is any column that is not pinned in place, while a fixed column is a column that is pinned to either the left or right side of the IGGridView. Inserting and deleting columns is very similar to inserting and deleting rows and cells. Use one of the following methods to inform the IGGridView control of updates to the underlying data.

  • -(void)insertColumnsAtIndexes:(NSArray *)indexes
  • -(void)deleteColumnsAtIndexes:(NSArray *)indexes
  • -(void)insertFixedLeftColumnsAtIndexes:(NSArray *)indexes
  • -(void)deleteFixedLeftColumnsAtIndexes:(NSArray *)indexes
  • -(void)insertFixedRightColumnsAtIndexes:(NSArray *)indexes
  • -(void)deleteFixedRightColumnsAtIndexes:(NSArray *)indexes

For inserting and deleting normal columns using a data source helper, the following methods are available.

  • -(void)insertColumns:(NSArray *)columns atIndex:(int)index
  • -(void)deleteColumns:(NSArray *)columns
Note: This only applies to data source helpers. If the data source needs updating after any column manipulations, such as moving, inserting, or deleting cells, rows, or columns, you will need to call the IGGridView method invalidateData with the BOOL parameter specified as NO. Failing to do so will result in all columns maintaining their original positions within the IGGridView and not displaying data updates.

Inserting and Deleting a Normal Column – Code Example


The following code example demonstrates how to insert and delete a normal column within the IGGridView.


In Objective-C:

//Insert normal column IGGridViewColumnDefinition* col = [[IGGridViewColumnDefinition alloc]initWithKey:@"prop1"]; [_dsh insertColumns:[NSArray arrayWithObjects:col, nil] atIndex:0]; [_gridView insertColumnsAtIndexes: [NSArray arrayWithObjects: @0, nil]]; //Delete normal column



[_dsh deleteColumns:[NSArray arrayWithObject:[_dsh.columns objectAtIndex:0]]];

[_gridView deleteColumnsAtIndexes:[NSArray arrayWithObject:@0]];

In C#:

//Insert left fixed column IGGridViewColumnDefinition col = new IGGridViewColumnDefinition("prop1");
dsh.InsertColumns(new NSObject[]{col}, 0);
grid.InsertColumns(new NSObject[]{new NSNumber(0)});

//Delete left fixed column dsh.DeleteColumns(new NSObject[]{dsh.Columns[0]});
grid.DeleteColumns(new NSObject[]{new NSNumber(0)});

Inserting and Deleting a Fixed Column – Code Example


The following code example demonstrates how to insert and delete a fixed column on the left side of the IGGridView.


In Objective-C:

//Insert left fixed column
IGGridViewColumnDefinition* colLeft = [[IGGridViewColumnDefinition alloc]initWithKey:@"prop1"];
colLeft.headerText = @"Fixed";
[_dsh.fixedLeftColumns insertObject:colLeft atIndex:0];
[_gridView insertFixedLeftColumnsAtIndexes:[NSArray arrayWithObject:[NSNumber numberWithInt:0]]];
//Delete left fixed column
[_dsh.fixedLeftColumns removeObjectAtIndex:0];
[_gridView deleteFixedLeftColumnsAtIndexes:[NSArray arrayWithObject:@0]];

In C#:

//Insert left fixed column IGGridViewColumnDefinition colLeft = new IGGridViewColumnDefinition("prop1");
colLeft.HeaderText = "Fixed";
dsh.FixedLeftColumns.Insert(colLeft, 0);
grid.InsertFixedLeftColumns(new NSObject[]{new NSNumber(0)});

//Delete left fixed column dsh.FixedLeftColumns.RemoveObject(0);
grid.DeleteFixedLeftColumns(new NSObject[]{new NSNumber(0)});

Related Content


The following topics provide additional information related to this topic.



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