示例#1
0
        /// <summary>
        /// Handles the OnDemandDataSourceLoad event of the dataPager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Syncfusion.Windows.Controls.Grid.GridDataOnDemandPageLoadingEventArgs"/> instance containing the event data.</param>
        private async void dataPager_OnDemandDataSourceLoad(object sender, GridDataOnDemandPageLoadingEventArgs e)
        {
            DataPagerExt ex          = e.Source as DataPagerExt;
            ViewModel    dataContext = this.AssociatedObject.DataContext as ViewModel;
            bool         IsCache     = false;

            //Assigning number of rows to be fetched from HBase
            HBaseOperation.FetchSize = 5000;

            if (!dataContext.ResultCollection.ContainsKey(ex.PageIndex) && HBaseOperation.HasRows)
            {
                dataContext.OrderDetails = await HBaseOperation.ScanTableAsync(dataContext.TableName, dataContext.Connection);

                dataContext.ResultCollection.Add(ex.PageIndex == -1 ? 1 : ex.PageIndex, dataContext.OrderDetails);
                IsCache = false;
            }
            else
            {
                dataContext.OrderDetails = dataContext.ResultCollection[ex.PageIndex];
                IsCache = true;
            }

            bool IsPrevious = PreviousPageIndex > ex.PageIndex;

            if (!IsPrevious && HBaseOperation.HasRows && !IsCache)
            {
                if (ex.PageIndex != -1)
                {
                    ex.PageCount = ex.PageCount + 1;
                }
            }

            PreviousPageIndex = ex.PageIndex == -1 ? 1 : ex.PageIndex;
        }
示例#2
0
        /// <summary>
        /// Handles the OnDemandDataSourceLoad event of the dataPager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Syncfusion.Windows.Controls.Grid.GridDataOnDemandPageLoadingEventArgs"/> instance containing the event data.</param>
        async void dataPager_OnDemandDataSourceLoad(object sender, GridDataOnDemandPageLoadingEventArgs e)
        {
            DataPagerExt ex          = e.Source as DataPagerExt;
            ViewModel    dataContext = this.AssociatedObject.DataContext as ViewModel;
            bool         IsCache     = false;

            if (!dataContext.ResultCollection.ContainsKey(ex.PageIndex) && dataContext.DataReader.HasRows)
            {
                dataContext.OrderDetails = await dataContext.DataReader.FetchResultAsync();

                dataContext.ResultCollection.Add(ex.PageIndex == -1 ? 1 : ex.PageIndex, dataContext.OrderDetails);
                IsCache = false;
            }
            else
            {
                dataContext.OrderDetails = dataContext.ResultCollection[ex.PageIndex];
                IsCache = true;
            }
            bool IsPrevious = PreviousPageIndex > ex.PageIndex;

            if (!IsPrevious && dataContext.DataReader.HasRows && !IsCache)
            {
                if (ex.PageIndex != -1)
                {
                    ex.PageCount = ex.PageCount + 1;
                }
            }
            PreviousPageIndex = ex.PageIndex == -1 ? 1 : ex.PageIndex;
        }