예제 #1
0
        public override void Refresh()
        {
            OnRowsChangedEventArgs args = new OnRowsChangedEventArgs();
            args.Rows = new List<int>();
            for (int i=0;i<Books.Count;i++)
            {
                args.Rows.Add(i);
            }

            this.OnRowsChanged.Notify(args, null, this);
        }
예제 #2
0
        public override void Refresh()
        {
            if (_suspendRefresh)
            {
                _refreshPending = true;
                return;
            }
            OnRowsChangedEventArgs args = new OnRowsChangedEventArgs();
            args.Rows = new List<int>();
            for (int i=0;i<Books.Count;i++)
            {
                args.Rows.Add(i);
            }

            this.OnDataLoaded.Notify(null, null, this);
            this.OnRowsChanged.Notify(args, null, this);
            
        }
        public override void Refresh()
        {
            //if (_suspendRefresh)
            //    return;

            _suspendRefresh = true;
            // check if we have loaded this page yet
            int firstRowIndex = (int)paging.PageNum * (int)paging.PageSize;

            // If we have deleted all rows, we don't want to refresh the grid on the first page
            bool allDataDeleted = (paging.TotalRows == 0) && (DeleteData != null) && (DeleteData.Count > 0);
            List<int> rows = new List<int>();
            if (firstRowIndex >= _pageLoaded)
            {
                this.OnDataLoading.Notify(null, null, null);

                string orderBy = ApplySorting();

                // We need to load the data from the server
                int? fetchPageSize;

                fetchPageSize = this.paging.PageSize ;
                if (String.IsNullOrEmpty(_fetchXml))
                    return;
                string parameterisedFetchXml = String.Format(_fetchXml, fetchPageSize, XmlHelper.Encode(this.paging.extraInfo), this.paging.PageNum + 1, orderBy);
                OrganizationServiceProxy.BeginRetrieveMultiple(parameterisedFetchXml, delegate(object result)
                {
                    try
                    {
                        EntityCollection results = OrganizationServiceProxy.EndRetrieveMultiple(result, _entityType);

                        // Set data
                        int i = firstRowIndex;
                        if (_lazyLoadPages)
                        {
                            // We are returning just one page - so add it into the data
                            foreach (Entity e in results.Entities)
                            {
                                _data[i] = (Entity)e;
                                ArrayEx.Add(rows,i);
                                i = i + 1;
                            }
                        }
                        else
                        {
                            // We are returning all results in one go
                            _data = results.Entities.Items();
                        }

                        // Notify
                        DataLoadedNotifyEventArgs args = new DataLoadedNotifyEventArgs();
                        args.From = firstRowIndex;
                        args.To = firstRowIndex+(int)paging.PageSize - 1;

                        this.paging.TotalRows = results.TotalRecordCount;
                        this.paging.extraInfo = results.PagingCookie;
                        this.paging.FromRecord = firstRowIndex + 1;
                        this.paging.TotalPages = Math.Ceil(results.TotalRecordCount / this.paging.PageSize);
                        this.paging.ToRecord = Math.Min(results.TotalRecordCount, firstRowIndex + paging.PageSize);
                        if (this._itemAdded)
                        {
                            this.paging.TotalRows++;
                            this.paging.ToRecord++;
                            this._itemAdded = false;
                        }
                        this.OnPagingInfoChanged.Notify(GetPagingInfo(), null, null);
                        this.OnDataLoaded.Notify(args, null, null);
                    }
                    catch (Exception ex)
                    {
                        this.ErrorMessage = ex.Message;
                        DataLoadedNotifyEventArgs args = new DataLoadedNotifyEventArgs();
                        args.ErrorMessage = ex.Message;
                        this.OnDataLoaded.Notify(args, null, null);
                    }
                });
            }
            else
            {
                // We already have the data
                DataLoadedNotifyEventArgs args = new DataLoadedNotifyEventArgs();
                args.From = 0;
                args.To = (int)paging.PageSize - 1;
                this.paging.FromRecord = firstRowIndex + 1;
                this.paging.ToRecord = Math.Min(this.paging.TotalRows, firstRowIndex + paging.PageSize);

                this.OnPagingInfoChanged.Notify(GetPagingInfo(), null, null);
                this.OnDataLoaded.Notify(args, null, null);
                this._itemAdded = false;

            }

            OnRowsChangedEventArgs refreshArgs = new OnRowsChangedEventArgs();
            refreshArgs.Rows = rows;

            this.OnRowsChanged.Notify(refreshArgs, null, this);
            _suspendRefresh = false;
        }
예제 #4
0
        public override void Refresh()
        {
            if (_suspend)
                return;

            // Flattern groups
            List<object> rows = new List<object>();
            FlatternGroups(rows, null,null, 0);
            _rows = rows;
         
            // Get the rows to invalidate
            OnRowsChangedEventArgs args = new OnRowsChangedEventArgs();
            args.Rows = new List<int>();
            int? startDiffRow = _refreshRowsAfter!=null ?_refreshRowsAfter : 0;

            for (int i = startDiffRow.Value; i < rows.Count; i++)
            {
                args.Rows.Add(i);
            }
           
            this.OnRowsChanged.Notify(args, null, null);
           


        }