Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Implementing Pull Down to Reload and Load More Rows on Demand
posted

Hi - I'm implementing both features mentioned above in one grid. The problem I am having is that when I implement the Pull Down to Reload feature it is making an addtional call out to the  IGGridViewDataSourceHelperLoadMoreDelegate.LoadMoreRows method. In other words when my view controller loads its making a call out to LoadMoreRows and I don't want it too and it's happening when I am implementing the Pull down to refresh feature.

If I comment out the:

//Set the overridden delegate to implement pull down to refresh.

gridView.Delegate = new gridViewDelegate (this);

Then everything works fine on the LoadMoreRows.


Not sure if my ordering of code is not right or if I need to combine these. Can you assist, below are some of my code snippets.

GRIDSETUP:

           //Set the overridden delegate to implement pull down to refresh.
            gridView.Delegate = new gridViewDelegate (this);

            //Next implement the load more helper
            dsh.LoadMoreDelegate = new LoadMoreHelper (gridView, this);

            //Next, set the data object
            dsh.Data = gridItemsSorted.ToArray ();

            // Set the DataSource
            gridView.DataSource = dsh;

            // Turn off empty rows
            gridView.EmptyRows = false;
 


CLASSES:

    public class LoadMoreHelper : IGGridViewDataSourceHelperLoadMoreDelegate
        {

            #region Members

            IGGridView gridView;
            RecentTestsTableViewController mRecentTestsTableViewController;

            #endregion

            #region Constructor

            public LoadMoreHelper (IGGridView GridView, RecentTestsTableViewController recentTestsTableViewController)
            {
                gridView = GridView;
                mRecentTestsTableViewController = recentTestsTableViewController;
            }

            #endregion

            #region Data Source Helper Methods

            public override IGGridViewLoadMoreCell ResolveLoadMoreCell (IGGridView gridView)
            {
                IGGridViewLoadMoreCell cell = (IGGridViewLoadMoreCell)gridView.DequeueReusableCell ("LoadMore");

                return cell;
            }

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

            public override void LoadMoreRows (IGGridViewDataSourceHelper dataSource)
            {
                mRecentTestsTableViewController.mPage++;

                if (mRecentTestsTableViewController.lstFunctionalTestGroupSummary.Count > 0)
                    mRecentTestsTableViewController.lstFunctionalTestGroupSummary.InsertRange (mRecentTestsTableViewController.lstFunctionalTestGroupSummary.Count - 1, LoadFunctionalTestGroup());

                //Rebind the datasource
                dataSource.Data = mRecentTestsTableViewController.lstFunctionalTestGroupSummary.ToArray ();

                //Update the display
                gridView.UpdateData ();

            }