/// <summary> /// Needs to be called as soon as it is desired to display the first 'Page' of data. /// </summary> /// <remarks>All further pages are loaded by the control on demand!</remarks> /// <param name="ADelegateGetDataPagedResultFunction">Delegate function that gets called /// when a Page of data needs to be retrieved. /// </param> /// <param name="AAddEmptyRows">Whether empty Rows for the data that *hasn't* been loaded /// in the first 'Data Page' should be added, or not. Set this to false if you are planning to call /// .AutoSizeCells() on the Grid and there is a possibility that there could be more than a couple of hundred /// records in total. The reason is that calling .AutoSizeCells() can take a considerable amount of time if there /// are many Cells to autosize (ie. the combination of Columns and Rows is high). If set to false, a separate /// call to the Method <see cref="AddEmptyRows" /> needs to be made by the caller after .AutoSizeCells() /// has been called on the Grid to add the empty rows at that point in time! (This results in the AutoSize only /// taking the first Data Page's rows into consideration for the auto-sizing, but that is why it will not be slow!)</param> /// <returns>A DataTable holding the records that fitted into the first 'Data Page'.</returns> public DataTable LoadFirstDataPage(TDelegateGetDataPagedResult ADelegateGetDataPagedResultFunction, bool AAddEmptyRows = true) { DataTable ReturnValue; TDataPageLoadEventArgs CustomEventArgs; // TLogging.Log("Enter LoadFirstDataPage..."); // TLogging.Log("LoadFirstDataPage: HScrollBarVisible: " + HScrollBarVisible.ToString()); DeterminePageSize(); FGetDataPagedResult = ADelegateGetDataPagedResultFunction; FLastHeight = this.Height; if (FGetDataPagedResult != null) { // Fire OnDataPageLoading event. CustomEventArgs = new TDataPageLoadEventArgs(); CustomEventArgs.DataPage = 0; this.OnDataPageLoading(CustomEventArgs); // Fetch the first page of data if (FPageSize < FMinimumPageSize) { FPageSize = FMinimumPageSize; } FPagedDataTable = FGetDataPagedResult(0, FPageSize, out FTotalRecords, out FTotalPages); ReturnValue = FPagedDataTable; DataTransferDone(AAddEmptyRows); // Fire OnDataPageLoaded event. CustomEventArgs = new TDataPageLoadEventArgs(); CustomEventArgs.DataPage = 0; this.OnDataPageLoaded(CustomEventArgs); } else { throw new EDataGridPagedDelegateFunctionNotSpecifiedException( "The " + this.GetType().FullName + " control is not properly initialised yet. " + "The ADelegateGetDataPagedResultFunction parameter of the InitialiseGrid method needs to be set to the delegate function that returns a page of data"); } FGridInitialised = true; // TLogging.Log("LoadFirstDataPage is finished."); return(ReturnValue); }
/// <summary> /// Needs to be called as soon as it is desired to display the first 'Page' of data. /// </summary> /// <remarks>All further pages are loaded by the control on demand!</remarks> /// <param name="ADelegateGetDataPagedResultFunction">Delegate function that gets called /// when a Page of data needs to be retrieved. /// </param> /// <param name="AAddEmptyRows">Whether empty Rows for the data that *hasn't* been loaded /// in the first 'Data Page' should be added, or not. Set this to false if you are planning to call /// .AutoSizeCells() on the Grid and there is a possibility that there could be more than a couple of hundred /// records in total. The reason is that calling .AutoSizeCells() can take a considerable amount of time if there /// are many Cells to autosize (ie. the combination of Columns and Rows is high). If set to false, a separate /// call to the Method <see cref="AddEmptyRows" /> needs to be made by the caller after .AutoSizeCells() /// has been called on the Grid to add the empty rows at that point in time! (This results in the AutoSize only /// taking the first Data Page's rows into consideration for the auto-sizing, but that is why it will not be slow!)</param> /// <returns>A DataTable holding the records that fitted into the first 'Data Page'.</returns> public DataTable LoadFirstDataPage(TDelegateGetDataPagedResult ADelegateGetDataPagedResultFunction, bool AAddEmptyRows = true) { DataTable ReturnValue; TDataPageLoadEventArgs CustomEventArgs; // TLogging.Log("Enter LoadFirstDataPage..."); // TLogging.Log("LoadFirstDataPage: HScrollBarVisible: " + HScrollBarVisible.ToString()); DeterminePageSize(); FGetDataPagedResult = ADelegateGetDataPagedResultFunction; FLastHeight = this.Height; if (FGetDataPagedResult != null) { // Fire OnDataPageLoading event. CustomEventArgs = new TDataPageLoadEventArgs(); CustomEventArgs.DataPage = 0; this.OnDataPageLoading(CustomEventArgs); // Fetch the first page of data if (FPageSize < FMinimumPageSize) { FPageSize = FMinimumPageSize; } FPagedDataTable = FGetDataPagedResult(0, FPageSize, out FTotalRecords, out FTotalPages); ReturnValue = FPagedDataTable; DataTransferDone(AAddEmptyRows); // Fire OnDataPageLoaded event. CustomEventArgs = new TDataPageLoadEventArgs(); CustomEventArgs.DataPage = 0; this.OnDataPageLoaded(CustomEventArgs); } else { throw new EDataGridPagedDelegateFunctionNotSpecifiedException( "The " + this.GetType().FullName + " control is not properly initialised yet. " + "The ADelegateGetDataPagedResultFunction parameter of the InitialiseGrid method needs to be set to the delegate function that returns a page of data"); } FGridInitialised = true; // TLogging.Log("LoadFirstDataPage is finished."); return ReturnValue; }