IGGridViewColumnDefinition Class Reference

Inherits from NSObject
Conforms to NSCoding
Declared in IGGridViewColumnDefinition.h

Overview

IGGridViewColumnDefinition is an object that is used by the IGGridViewDataSourceHelper classes to identify properties on the underlying data objects.

For example, if I had an array of objects of type MyClass. And MyClass had three properties: firstName, lastName and age. I could create a column definition for my firstName property:

colDef = [[IGGridViewColumnDefinition alloc] initWithKey:@"firstName"];

colDef.headerText = "@First Name";

The real benefits of using column definitions comes with the ability to create your own derived versions that override the gridView:createCell:usingDataSource: method. By doing so, you can specify any custom cell that you want to display in the column. For example: the IGGridViewImageColumnDefinition creates a column that uses the IGGridViewImageCell.

Note: when deriving your own column defition, you should follow the same practice of using the grid view’s dequeueReusableCellWithIdentifier: method.

Configuring the Column Definition

– initWithKey:

Creates an IGGridViewColumnDefinition for the specified property name.

- (instancetype)initWithKey:(NSString *)key

Parameters

key

A string that maps to an actual property on your underlying data object.

Return Value

Returns an initialized IGGridViewColumnDefinition object or nil if the object could not be successfully initialized.

Declared In

IGGridViewColumnDefinition.h

  fieldKey

The name of the property that this column definition represents (readonly)

@property (nonatomic, retain, readonly) NSString *fieldKey

Declared In

IGGridViewColumnDefinition.h

  headerText

The value that should be display in the header of the IGGridView for this column.

@property (nonatomic, retain) NSString *headerText

Declared In

IGGridViewColumnDefinition.h

  textColor

The font color of the text field.

@property (nonatomic, retain) UIColor *textColor

Declared In

IGGridViewColumnDefinition.h

  textFont

The font of the text field.

@property (nonatomic, retain) UIFont *textFont

Declared In

IGGridViewColumnDefinition.h

  textAlignment

The alignment of the text field.

@property (nonatomic, assign) NSTextAlignment textAlignment

Declared In

IGGridViewColumnDefinition.h

  headerTextAlignment

The alignment of the header text field.

@property (nonatomic, assign) NSTextAlignment headerTextAlignment

Declared In

IGGridViewColumnDefinition.h

  backgroundColor

The background color for every cell in the column.

@property (nonatomic, retain) UIColor *backgroundColor

Declared In

IGGridViewColumnDefinition.h

  width

The width of the column. The default is nil.

@property (nonatomic, retain) IGColumnWidth *width

Discussion

Note: This has lower priority than if the delegate specifies the width for the column.

Declared In

IGGridViewColumnDefinition.h

Editing

  editable

Determines whether this particular column can be put into edit mode.

@property (nonatomic, assign) BOOL editable

Declared In

IGGridViewColumnDefinition.h

– gridView:displayEditorForCell:usingDataSource:

Asks the column definition to display an editor for a cell.

- (void)gridView:(IGGridView *)gridView displayEditorForCell:(IGCellPath *)path usingDataSource:(IGGridViewDataSourceHelper *)dataSource

Parameters

gridView

The grid view requesting the cell to be placed in edit mode.

path

The path of the cell that should be placed in edit mode.

dataSource

The IGGridViewDataSourceHelper that has invoked this method.

Declared In

IGGridViewColumnDefinition.h

– gridView:removeEditorForCell:usingDataSource:isCellStillVisible:isAnotherCellEnteringEditMode:

Asks the column definition to remove its editor.

- (void)gridView:(IGGridView *)gridView removeEditorForCell:(IGCellPath *)path usingDataSource:(IGGridViewDataSourceHelper *)dataSource isCellStillVisible:(BOOL)cellVisible isAnotherCellEnteringEditMode:(BOOL)anotherCellEnteringEditMode

Parameters

gridView

The grid view requesting the editor to be removed.

path

The path of the cell that is currently in edit mode.

dataSource

The IGGridViewDataSourceHelper that has invoked this method.

cellVisible

Tells the method whether the cell that was in edit mode is still in the grid’s viewport.

anotherCellEnteringEditMode

Tells the method whether this cell is exiting edit mode b/c another cell is currently in edit mode.

Declared In

IGGridViewColumnDefinition.h

Protected Members

– gridView:createCell:usingDataSource:

Asks the column definition for a cell to place at a particular location in the grid view.

- (IGGridViewCell *)gridView:(IGGridView *)gridView createCell:(IGCellPath *)path usingDataSource:(IGGridViewDataSourceHelper *)dataSource

Parameters

gridView

The grid view requesting the cell.

path

The path of the cell that is needed

dataSource

The IGGridViewDataSourceHelper that has invoked this method.

Return Value

An object inheriting IGGridViewCell that the grid view can use for the specified location.

Discussion

The returned IGGridViewCell object is frequently one that the application reuses for performance reasons. You should fetch a previously created cell object that is marked for reuse by sending a dequeueResuableCellWithIdentifier: message to the grid view. The identifier for a reusable cell object is assigned when the the initWithStyle:reuseIdentifier: method of the IGGridViewCell.

Declared In

IGGridViewColumnDefinition.h

– gridView:createHeaderCellUsingDataSource:

Asks the column definition for a header cell to place at a particular location in the grid view.

- (IGGridViewHeaderCell *)gridView:(IGGridView *)gridView createHeaderCellUsingDataSource:(IGGridViewDataSourceHelper *)dataSource

Parameters

gridView

The grid view requesting the cell.

dataSource

The IGGridViewDataSourceHelper that has invoked this method.

Return Value

An object inheriting IGGridViewHeaderCell that the grid view can use for the specified location.

Discussion

The returned IGGridViewHeaderCell object is frequently one that the application reuses for performance reasons. You should fetch a previously created cell object that is marked for reuse by sending a dequeueResuableCellWithIdentifier: message to the grid view. The identifier for a reusable cell object is assigned when the the initWithStyle:reuseIdentifier: method of the IGGridViewCell.

Declared In

IGGridViewColumnDefinition.h

– setText:onCell:forDataSource:

Sets the text provided to the cell’s text label.

- (void)setText:(NSString *)text onCell:(IGGridViewCell *)cell forDataSource:(IGGridViewDataSourceHelper *)dataSource

Parameters

text

The text to be set on the cell.

cell

The cell that should be updated.

dataSource

The datasource being used.

Discussion

This method allows a cell to be updated properly. Especially if there is a filter applied and a special string attributes such as font color should be applied to the cell’s text.

Declared In

IGGridViewColumnDefinition.h

– applyStylingToCell:AtRow:inGrid:

Call this from a derived class to ensure the proper styling is applied to your cell.

- (void)applyStylingToCell:(IGGridViewCell *)cell AtRow:(NSInteger)rowIndex inGrid:(IGGridView *)gridView

Parameters

cell

The cell that should be updated.

rowIndex

The index of the row for the cell beging updated.

gridView

The gridView that the cell belongs to.

Declared In

IGGridViewColumnDefinition.h

– resolveValueForObject:inDataSource:

Given an object, it returns a string value of the underlying property this column represents.

- (NSString *)resolveValueForObject:(id)obj inDataSource:(IGGridViewDataSourceHelper *)dsh

Parameters

obj

The underlying data object mapped to the cell.

dsh

The IGGridViewDataSourceHelper that this column belongs to.

Return Value

A string representation of the value that this column represents.

Discussion

If your derived column is not representing a property, you should override this to resolve the correct value

Declared In

IGGridViewColumnDefinition.h

– resolveHeightforPath:inGrid:usingWidth:inDataSource:

Asks the column what the height that this column needs for a given row.

- (CGFloat)resolveHeightforPath:(IGRowPath *)path inGrid:(IGGridView *)gridView usingWidth:(CGFloat)width inDataSource:(IGGridViewDataSourceHelper *)dataSource

Parameters

path

The section and row whose height is being asked for.

gridView

The IGGridView that this column belongs to.

width

The actual width value of the column.

dataSource

The IGGridViewDataSourceHelper that this column belongs to.

Return Value

The total height for the content being displayed in this column given the specific row and section.

Discussion

This method is only invoked if the IGGridViewDataSourceHelper is resolving

Declared In

IGGridViewColumnDefinition.h