Configuring the Loading More Rows Functionality
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic provides a conceptual overview of the IGGridView™ control’s loading more rows functionality and uses code to demonstrate its configuration.

Required background

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

Topic

Purpose

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


Introduction

Loading more rows summary

Triggered by the user scrolls to the bottom of the IGGridView with the “loading more” row is in view adds more rows by automatically calling the IGGridViewDataSourceHelperLoadMoreDelegate protocol method. To implement this feature, you first need to set the data source helper’s loadMoreDelegate property to a class object that implements the IGGridViewDataSourceHelperLoadMoreDelegate protocol.

Note: The loading more rows functionality is only available through data source helpers.

Loading More Rows Delegate Implementation – Code Example

Description

The IGGridViewDataSourceHelperLoadMoreDelegate protocol has three required methods to implement: loadMoreRows, cellForLoadingMore, and needMoreRows. The following code demonstrates the handling of each of these protocol methods.

Prerequisites

This code example requires that you create and implement the IGGridViewDataSourceHelperLoadMoreDelegate in a class named loadMoreCell.

Code

In Objective-C:

-(IGGridViewLoadMoreCell *)cellForLoadingMore:(IGGridView *)gridView 
{
    NSString* lookup = @"LOAD_MORE";
    IGGridViewLoadMoreCell *cell = [gridView dequeueReusableCellWithIdentifier:lookup];
    if (cell == nil) 
    {
        cell = [[IGGridViewLoadMoreCell alloc] initWithReuseIdentifier:lookup];
    }
    
    cell.textLabel.textAlignment = UITextAlignmentCenter;
    cell.textLabel.text = @"Loading More Movies...";
    return cell;
}
-(BOOL)needMoreRows:(IGGridViewDataSourceHelper *)dataSource
{
    return (dataSource.data.count < 200);
}
-(void)loadMoreRows:(IGGridViewDataSourceHelper *)dataSource
{
    IGGridViewDataSourceHelper *dataSource = _gridView.dataSource;
    [dataSource appendData:newData];
    [_gridView updateData];
}

In C#:

public class LoadMoreHelper : IGGridViewDataSourceHelperLoadMoreDelegate
 {
  public override IGGridViewLoadMoreCell ResolveLoadMoreCell (IGGridView gridView)
  {
   IGGridViewLoadMoreCell cell = (IGGridViewLoadMoreCell)gridView.DequeueReusableCell("LoadMore");
   if(cell == null)
     cell = new IGGridViewLoadMoreCell("LoadMore");

   cell.TextLabel.TextAlignment = UITextAlignment.Center;
   cell.TextLabel.Text = "Load More...";

   return cell;
  }

  public override bool NeedMoreRows (IGGridViewDataSourceHelper dataSource)
  {
   return dataSource.Data.Length < 200;
  }

  public override void LoadMoreRows (IGGridViewDataSourceHelper dataSource)
  {
   // Add data to datasource

   // Update the gridView:
   _gridView.UpdateData();
  }
 }

Implementation

Both the preceding and following code examples demonstrate how to implement the load more cells functionality by assigning the class object implementing the IGGridViewDataSourceHelperLoadMoreDelegate protocol to the loadMoreDelegate property. Furthermore, both examples assume that you have created and implemented the IGGridViewDataSourceHelperLoadMoreDelegate in a class named loadMoreCell.

In Objective-C:

    IGGridViewDataSourceHelper* ds = [[IGGridViewDataSourceHelper alloc]init];    
    // Must set the LoadMoreDelegate property on the DataSourceHelper
    ds.loadMoreDelegate = self;

In C#:

   IGGridViewDataSourceHelper ds = new IGGridViewDataSourceHelper();
   ds.LoadMoreDelegate = new LoadMoreHelper();

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 with getting up and running with using the control.

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