Inherits from NSObject
Conforms to IGGridViewDataSource
Declared in IGGridViewDataSourceHelper.h

Overview

The IGGridViewDataSourceHelper is basically just what it sounds like. If you’re just trying to display an array of your custom objects, then it can be quite tedious to re-implement the IGGridViewDataSource protocol for every IGGridView you’ve implemented. The purpose of this class is to save you from writing a bunch of extra code.

You simply set the data property and you’re done. The data source will automatically walk your objects and create a column for every public property. If you don’t want it to do that, you can set the autoGenerateColumns property to NO, and specify the columns in your own order using the columnDefinitions property and adding your IGGridViewColumnDefinition objects to the array.

The datasource helper class will even group your data for sections. All you need to do is set the groupingKey property to the name of a property on your custom object. For example, say I have an object call MyData. On MyData I have three properties: firstName, lastName and age. If I wanted to organize my data into sections based on the lastName, I would simply do the following:

    dataSource.groupingKey = @"lastName";

Likewise, if i’d like to enable filtering on my IGGridView, I can set the filteringKey property. So, to filter the data by firstName, I would do the following.

    datasource.filteringKey= @"firstName";

The dataSource helper, even makes it easy to enable features such as displaying section header and footers, row reordering, or even the shortcut bar, simply by setting YES or NO on a few properties.

If you want to find the direct mapping of a IGCellPath or IGRowPath to your actual objects, you can use the resolve methods exposed on this class.

However, the real power is the ability to reorganzie your data into different ways. For example: the IGGridViewSingleRowSingleFieldDataSourceHelper class will actually flip your rows into columns. To create your own DataSourceHelper class is actually rather simple. You can override any of the IGGridViewDataSource protocol methods, and if you change how the data maps to the IGCellPath objects, you can simply override the normalizePath method to map a cell path back to your data.

Tasks

Configuring Data

Setup whats displayed

Data Updates

Data Manipulation

Data Access

Load More

Filtering

Fixed Columns

Protected Overrides

Properties

_0

A readonly dictionary, that can be used in iOS 6 and greater to highlight the text that applies to the filter.

@property (nonatomic, readonly) NSDictionary *NS_AVAILABLE_IOS ( 6 _0

Declared In

IGGridViewDataSourceHelper.h

allowColumnReordering

YES if column reordering is allowed, or NO if it is not.

@property (nonatomic, assign) BOOL allowColumnReordering

Declared In

IGGridViewDataSourceHelper.h

allowRowReordering

Gets or sets whether row reordering is allowed for this data

@property (nonatomic, assign) BOOL allowRowReordering

Discussion

You would still have to turn on row reordering on the IGGridView to turn on ths feature, this just gives you the option to override it on the datasource level, and say that its not supported.

Declared In

IGGridViewDataSourceHelper.h

autoGenerateColumns

A boolean value that controls whether columns will automatically be created by looking at the properties of the underlying data objects.

@property (nonatomic, assign) BOOL autoGenerateColumns

Declared In

IGGridViewDataSourceHelper.h

columnDefinitions

A collection of developer specified IGColumnDefinition objects that should be displayed in the IGGridView

@property (nonatomic, readonly) NSMutableArray *columnDefinitions

Declared In

IGGridViewDataSourceHelper.h

columns

A readonly list of IGGridViewColumnDefinition objects that represent all the columns that will be displayed by the datasource.

@property (nonatomic, readonly) NSArray *columns

Discussion

This list contains both the columns specified in the columnDefinitions property and any autoGeneratedColumns.

Declared In

IGGridViewDataSourceHelper.h

data

Gets or sets the array of data that will be consumed by the IGGridViewDataSourceHelper

@property (nonatomic, retain) NSArray *data

Discussion

As of right now, the data must be of a derivation of NSObject and have at least one property.

Declared In

IGGridViewDataSourceHelper.h

deleteRowAnimation

Gets or sets the type of animation that will occur when you delete a row.

@property (nonatomic, assign) IGGridViewAnimation deleteRowAnimation

Declared In

IGGridViewDataSourceHelper.h

displayData

A readonly list that provides the data currently being dislayed.

@property (nonatomic, readonly) NSArray *displayData

Discussion

This is useful for example if you’ve filtered your data, displayData would contain just the items that match the filter. Note: it only contains data when there are no sections, i.e. the goupingKey property is not set.

Declared In

IGGridViewDataSourceHelper.h

displayShortcutbar

Gets or sets whether the shortcut bar should be displayed.

@property (nonatomic, assign) BOOL displayShortcutbar

Discussion

If set to YES the groupingKey must also be set, in order for the shortcutbar to be displayed.

Declared In

IGGridViewDataSourceHelper.h

fieldsToIgnore

A collection of strings that map to properties in the underlying data object that should not be autogenerated

@property (nonatomic, readonly) NSMutableArray *fieldsToIgnore

Declared In

IGGridViewDataSourceHelper.h

filterShortcutbarValue

Gets or sets the string that will be displayed in the shortcutbar.

@property (nonatomic, retain) NSString *filterShortcutbarValue

Discussion

The default is a magnifying glass.

Declared In

IGGridViewDataSourceHelper.h

filterType

Gets or sets the type of filtering condition that will be applied to the property associated with the filteringKey.

@property (nonatomic, assign) IGGridViewFilterConditionType filterType

Discussion

The default is IGGridViewFilterConditionTypeStringContains.

Declared In

IGGridViewDataSourceHelper.h

filterValue

The value that the datasource is currently filtered by.

@property (nonatomic, readonly) NSString *filterValue

Discussion

This property is readonly.

Declared In

IGGridViewDataSourceHelper.h

filteringCaseInsensitivity

Gets or sets a Boolean value that determines if filtering will be case insensitive.

@property (nonatomic, assign) BOOL filteringCaseInsensitivity

Discussion

The default value is YES.

Declared In

IGGridViewDataSourceHelper.h

filteringDiacriticInsensitiveFiltering

Gets or sets a Boolean value that determines if filtering will be diacritic insensitive.

@property (nonatomic, assign) BOOL filteringDiacriticInsensitiveFiltering

Discussion

For example: Two diacritics appear in the word “déjà vu, when YES, they would be ignored. The default value is YES.

Declared In

IGGridViewDataSourceHelper.h

filteringKey

Gets or sets a string that represents a property on the underlying data objects.

@property (nonatomic, retain) NSString *filteringKey

Discussion

The data can then be filterd by the specified property. Note if you want the data to be filterd by the entire object, i.e. your data is an array of strings, you should set the value of the property to “self”

Declared In

IGGridViewDataSourceHelper.h

fixedLeftColumns

A list of IGGridViewColumnDefinition objects that represent columns pinned to the left of the grid view.

@property (nonatomic, readonly) NSMutableArray *fixedLeftColumns

Declared In

IGGridViewDataSourceHelper.h

fixedRightColumns

A list of IGGridViewColumnDefinition objects that represent columns pinned to the right of the grid view.

@property (nonatomic, readonly) NSMutableArray *fixedRightColumns

Declared In

IGGridViewDataSourceHelper.h

groupingKey

Gets or sets a string that represents a property on the underlying data objects.

@property (nonatomic, retain) NSString *groupingKey

Discussion

The data is in the grouped by unique values of this property in the array of data that was assigned to the datasource Note if you want the data to be grouped by the entire object, i.e. your data is an array of strings, you should set the value of the property to “self”

Declared In

IGGridViewDataSourceHelper.h

groupingSortDirection

The direction in which data should be sorted for the grouping of data specified by the groupingKey

@property (nonatomic, assign) IGGridViewSortedColumnDirection groupingSortDirection

Discussion

The default is IGGridViewSortedColumnDirectionAscending.

Declared In

IGGridViewDataSourceHelper.h

loadMoreDelegate

A delegate for loading more rows.

@property (nonatomic, assign) id<> loadMoreDelegate

Discussion

Check out the IGGridViewDataSourceHelperLoadMoreDelegate documentation for more details.

Declared In

IGGridViewDataSourceHelper.h

sectionData

A readonly dictionary, where the key is each value in the sections property, that contains a list of data for that section

@property (nonatomic, readonly) NSDictionary *sectionData

Declared In

IGGridViewDataSourceHelper.h

sectionFooterEnabled

Gets or sets whether the headers for sections should be displayed

@property (nonatomic, assign) BOOL sectionFooterEnabled

Discussion

The groupingKey must also be set.

Declared In

IGGridViewDataSourceHelper.h

sectionHeaderEnabled

Gets or sets whether the footers for sections should be displayed

@property (nonatomic, assign) BOOL sectionHeaderEnabled

Discussion

The groupingKey must also be set.

Declared In

IGGridViewDataSourceHelper.h

sections

A readonly list that contains all of the unique keys used for the sections.

@property (nonatomic, readonly) NSArray *sections

Discussion

These are the values that will be used in the shortcutbar. Note this property only is set when there is a groupingKey provided.

Declared In

IGGridViewDataSourceHelper.h

sortedColumns

A collection of developer specified IGGridViewSortedColumn objects in the order in which the data should be sorted by.

@property (nonatomic, readonly) NSMutableArray *sortedColumns

Discussion

The first IGGridViewSortedColumn in the collection will have the highest priority. If the data is grouped using the groupingKey property, then the field being grouped will have the highest priority. To control the direction of the grouped field, use the groupingSortDirection property.

Declared In

IGGridViewDataSourceHelper.h

Instance Methods

appendData:

Takes the newly specified data, and appends it to the original data provided to the datasource helper.

- (void)appendData:(NSArray *)newData

Parameters

newData

An array of data that should be appended to the end of the data already assigned to the datasource helper.

Declared In

IGGridViewDataSourceHelper.h

applyFilterForValue:toData:

When overriden, a developer can provide their own custom filtering to the data.

- (NSArray *)applyFilterForValue:(NSString *)value toData:(NSArray *)dataToFilter

Parameters

value

The string that the data should be filtered by.

dataToFilter

An NSArray that contains the data that should be filtered.

Return Value

An array of filtered data.

Discussion

This should be overriden if you want to provide your own custom filtering.

Declared In

IGGridViewDataSourceHelper.h

deNormalizePath:

Given a IGCellPath that maps to the underlying data, it converts it to a path that maps to the display.

- (IGCellPath *)deNormalizePath:(IGCellPath *)path

Parameters

path

An IGCellPath that maps to the underlying data.

Return Value

An IGCellPath that has maps to a cell in the grid.

Discussion

This should be overriden if you change how your data is being displayed, for example if you swapped rows and columns

Declared In

IGGridViewDataSourceHelper.h

deleteColumns:

Deletes the specified IGGridViewColumnDefinition objects.

- (void)deleteColumns:(NSArray *)columns

Parameters

columns

An array of IGGridViewColumnDefinition objects to remove from the grid view.

Declared In

IGGridViewDataSourceHelper.h

insertColumns:atIndex:

Inserts the specified IGGridViewColumnDefinition objects at the specified index.

- (void)insertColumns:(NSArray *)columns atIndex:(int)index

Parameters

columns

An array of IGGridViewColumnDefinition objects to insert into the grid view.

index

The index in which to insert the columns.

Declared In

IGGridViewDataSourceHelper.h

invalidateData

Tells the datasource helper to revaulate its data.

- (void)invalidateData

Discussion

Such as calcuating the secions, applying a filter or sort, calculating how many rows are in the datasource and even regenerating columns.

Declared In

IGGridViewDataSourceHelper.h

invalidateData:

Tells the datasource helper to revaulate its data.

- (void)invalidateData:(BOOL)invalidateColumns

Parameters

invalidateColumns

YES if columns should be reset and regenerated.

Discussion

Such as calcuating the secions, applying a filter or sort, calculating how many rows are in the datasource and even regenerating columns.

Declared In

IGGridViewDataSourceHelper.h

normalizePath:

Given a IGCellPath it is converted to a path that realistically maps to the underlying data.

- (IGCellPath *)normalizePath:(IGCellPath *)path

Parameters

path

An IGCellPath that maps to a cell in the IGGridView.

Return Value

An IGCellPath that has been converted to map to an actuall item in your data source.

Discussion

This should be overriden if you change how your data is being displayed, for example if you swapped rows and columns

Declared In

IGGridViewDataSourceHelper.h

resolveCellPathForData:

Does a reverse lookup to find the cell for the specified value

- (IGCellPath *)resolveCellPathForData:(NSObject *)data

Parameters

data

The data object to look up in the array of data assigned to datasource

Return Value

A path to the cell location of the specified data object, or nil if it isn’t found.

Declared In

IGGridViewDataSourceHelper.h

resolveDataObjectForRow:

Given an IGRowPath, it identifies the data object at that position in the array.

- (id)resolveDataObjectForRow:(IGRowPath *)path

Parameters

path

An IGRowPath that maps to a row in the IGGridView.

Return Value

The an item from the array assigned to the datasource.

Declared In

IGGridViewDataSourceHelper.h

resolveDataValueForCell:

Given an IGCellPath, it identifies the data object and specific property value.

- (id)resolveDataValueForCell:(IGCellPath *)path

Parameters

path

An IGCellPath that maps to a cell in the IGGridView.

Return Value

The property value for the given path.

Declared In

IGGridViewDataSourceHelper.h