Example #1
0
        internal static bool RaiseGroupByChanging(
            GridViewTemplate template,
            GroupDescriptor groupDescription,
            NotifyCollectionChangedAction action)
        {
            GridGroupByExpression fromDescriptor = GridGroupByExpression.CreateFromDescriptor(groupDescription);
            GridViewCollectionChangingEventArgs args;

            if (action == NotifyCollectionChangedAction.Add || action == NotifyCollectionChangedAction.ItemChanged || action == NotifyCollectionChangedAction.Remove)
            {
                args = new GridViewCollectionChangingEventArgs(template, action, (object)fromDescriptor, 0, 0);
            }
            else
            {
                if (action != NotifyCollectionChangedAction.Batch)
                {
                    throw new ArgumentException("Invalid action");
                }
                IList newItems = (IList) new List <GridGroupByExpression>();
                newItems.Add((object)fromDescriptor);
                args = new GridViewCollectionChangingEventArgs(template, action, newItems, (IList)template.GroupDescriptors, 0, 0, (PropertyChangingEventArgsEx)null);
            }
            template.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.GroupByChanging, (object)template, args);
            if (!args.Cancel)
            {
                template.EventDispatcher.SuspendEvent(EventDispatcher.GroupByChanging);
                template.EventDispatcher.SuspendEvent(EventDispatcher.GroupByChanged);
                template.MasterTemplate.SynchronizationService.BeginDispatch();
            }
            return(args.Cancel);
        }
Example #2
0
 private bool OnRowsChanging(GridViewCollectionChangingEventArgs e)
 {
     if (this.owner.IsUpdating)
     {
         return(false);
     }
     if (e.Cancel)
     {
         return(e.Cancel);
     }
     this.owner.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.RowsChanging, (object)this.owner, e);
     return(e.Cancel);
 }
Example #3
0
        private void radGridView5_RowsChanging(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e)
        {
            var commandServer = new CommandServer();

            if (e.Action == NotifyCollectionChangedAction.ItemChanging)
            {
                var line = (GridViewRowInfo)e.NewItems[0];

                if (line.Cells[0].Value != null)
                {
                    commandServer.ExecNoReturnServer("EverySet_edit", line.Cells[0].Value.ToString() + "'" + line.Cells[1].Value.ToString() + "'");
                }
            }
        }
Example #4
0
        private bool RaiseSortingChanging(SortDescriptor descriptor)
        {
            if (this.ownerTemplate == null)
            {
                return(false);
            }
            GridViewCollectionChangingEventArgs args = new GridViewCollectionChangingEventArgs(this.ownerTemplate, NotifyCollectionChangedAction.Batch, (IList) new List <SortDescriptor>()
            {
                descriptor
            }, (IList)this.ownerTemplate.SortDescriptors, -1, -1, (PropertyChangingEventArgsEx)null);

            this.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.SortChangingEvent, (object)this.ownerTemplate, args);
            return(args.Cancel);
        }
 private bool OnGroupByChanging(GridViewCollectionChangingEventArgs e)
 {
     if (this.Suspended)
     {
         return(false);
     }
     if (this.CollectionChanging != null)
     {
         this.CollectionChanging((object)this, (NotifyCollectionChangingEventArgs)e);
     }
     if (e.Cancel)
     {
         return(e.Cancel);
     }
     this.owner.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.GroupByChanging, (object)this.owner, e);
     return(e.Cancel);
 }
Example #6
0
 internal virtual object this[GridViewColumn column]
 {
     get
     {
         if (this.IsAttached)
         {
             return(column.Accessor[this]);
         }
         if (this.rowState == null)
         {
             return((object)null);
         }
         return(this.Cache[column]);
     }
     set
     {
         bool flag = this.ViewTemplate.MasterTemplate != null && this.ViewTemplate.MasterTemplate.VirtualMode;
         if (!flag && !this.AddingNewDataRow && !this.ViewTemplate.IsUpdating)
         {
             GridViewCollectionChangingEventArgs args = new GridViewCollectionChangingEventArgs(this.ViewTemplate, Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanging, (object)this, (object)this, this.Index, new PropertyChangingEventArgsEx(column.FieldName, this[column], value));
             this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.RowsChanging, (object)this, args);
             if (args.Cancel)
             {
                 return;
             }
         }
         if (this.IsAttached)
         {
             column.Accessor[this] = value;
         }
         else
         {
             this.Cache[column] = value;
             if (flag || this.IsSystem)
             {
                 return;
             }
             GridViewCollectionChangedEventArgs args = new GridViewCollectionChangedEventArgs(this.ViewTemplate, Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanged, (object)this, (object)this, this.Index, column.FieldName);
             this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewCollectionChangedEventArgs>(EventDispatcher.RowsChanged, (object)this, args);
         }
     }
 }
Example #7
0
 private bool OnFilterChanging(GridViewCollectionChangingEventArgs e)
 {
     if (this.Suspended)
     {
         return(true);
     }
     this.owner.ProcessingData = true;
     this.owner.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.FilterChangingEvent, (object)this.owner, e);
     if (e.Cancel)
     {
         this.owner.ProcessingData = false;
         return(false);
     }
     this.owner.ProcessingData = false;
     if (this.CollectionChanging != null)
     {
         this.CollectionChanging((object)this, (NotifyCollectionChangingEventArgs)e);
     }
     return(!e.Cancel);
 }
Example #8
0
        public GridViewRowInfo EndAddNewRow()
        {
            if (!this.newRowInitialized || !this.IsModified)
            {
                return((GridViewRowInfo)null);
            }
            GridViewCollectionChangingEventArgs args1 = new GridViewCollectionChangingEventArgs(this.ViewTemplate, Telerik.WinControls.Data.NotifyCollectionChangedAction.Add, (object)null, this.ViewTemplate.Rows.Count, -1);

            this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.RowsChanging, (object)this.ViewTemplate, args1);
            if (args1.Cancel)
            {
                return((GridViewRowInfo)null);
            }
            GridViewRowCancelEventArgs args2 = new GridViewRowCancelEventArgs(new GridViewRowInfo[1]
            {
                (GridViewRowInfo)this
            });

            this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowCancelEventArgs>(EventDispatcher.UserAddingRow, (object)this.ViewTemplate, args2);
            if (args2.Cancel)
            {
                return((GridViewRowInfo)null);
            }
            if (this.ViewTemplate.IsVirtualRows)
            {
                GridViewObjectRelationalDataProvider hierarchyDataProvider = this.ViewTemplate.HierarchyDataProvider as GridViewObjectRelationalDataProvider;
                GridViewRowInfo rowInfo = (GridViewRowInfo)this;
                if (hierarchyDataProvider != null && this.ViewTemplate.AutoUpdateObjectRelationalSource)
                {
                    rowInfo = hierarchyDataProvider.AddNewRow(this) ?? (GridViewRowInfo)this;
                    this.ViewInfo.Refresh();
                    if (rowInfo != this)
                    {
                        if (!this.deferUserAddedRow)
                        {
                            GridViewRowEventArgs args3 = new GridViewRowEventArgs(rowInfo);
                            this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowEventArgs>(EventDispatcher.UserAddedRow, (object)this.ViewTemplate, args3);
                        }
                        else
                        {
                            this.addedRow          = rowInfo;
                            this.deferUserAddedRow = false;
                        }
                        if (this.moveToLastRow)
                        {
                            rowInfo.IsCurrent  = true;
                            this.moveToLastRow = false;
                        }
                        else
                        {
                            this.ViewTemplate.MasterTemplate.CurrentRow = (GridViewRowInfo)this.ViewInfo.TableAddNewRow;
                        }
                    }
                }
                else
                {
                    GridViewRowEventArgs args3 = new GridViewRowEventArgs((GridViewRowInfo)this);
                    this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowEventArgs>(EventDispatcher.UserAddedRow, (object)this.ViewTemplate, args3);
                }
                GridViewSynchronizationService.DispatchEvent(this.ViewTemplate, new GridViewEvent((object)this.ViewTemplate, (object)this.ViewTemplate, new object[1]
                {
                    (object)new DataViewChangedEventArgs(ViewChangedAction.Add, (object)this)
                }, new GridViewEventInfo(KnownEvents.ViewChanged, GridEventType.Both, GridEventDispatchMode.Send)), false);
                return(rowInfo);
            }
            int             count    = this.ViewTemplate.ListSource.Count;
            GridViewRowInfo rowInfo1 = this.boundRow;

            try
            {
                this.ViewTemplate.Rows.addingThroughUI = true;
                this.ViewTemplate.BeginUpdate();
                IEditableObject editableObject = rowInfo1 != null ? rowInfo1.DataBoundItem as IEditableObject : (IEditableObject)null;
                if (rowInfo1 == null)
                {
                    rowInfo1       = this.ViewTemplate.ListSource.AddNew();
                    editableObject = rowInfo1.DataBoundItem as IEditableObject;
                    editableObject?.BeginEdit();
                }
                else
                {
                    this.boundRow.IsVisible = true;
                }
                rowInfo1.AddingNewDataRow = true;
                bool flag = false;
                for (int index = 0; index < this.ViewTemplate.Columns.Count; ++index)
                {
                    GridViewColumn column = (GridViewColumn)this.ViewTemplate.Columns[index];
                    object         obj    = this[column];
                    if (obj == null)
                    {
                        GridViewCheckBoxColumn viewCheckBoxColumn = column as GridViewCheckBoxColumn;
                        if (viewCheckBoxColumn != null && viewCheckBoxColumn.DataType.IsValueType)
                        {
                            object instance = Activator.CreateInstance(viewCheckBoxColumn.DataType);
                            rowInfo1[column] = instance;
                        }
                    }
                    else if (this.changedColumns.Contains((object)column))
                    {
                        flag             = true;
                        rowInfo1[column] = obj;
                    }
                }
                if (flag)
                {
                    editableObject?.EndEdit();
                    this.ViewTemplate.EndUpdate(false);
                    GridViewSynchronizationService.SuspendEvent(this.ViewTemplate, KnownEvents.CurrentChanged);
                    ((ICancelAddNew)this.ViewTemplate.ListSource).EndNew(this.ViewTemplate.ListSource.Count - 1);
                    GridViewSynchronizationService.ResumeEvent(this.ViewTemplate, KnownEvents.CurrentChanged);
                    if (!this.deferUserAddedRow)
                    {
                        GridViewRowEventArgs args3 = new GridViewRowEventArgs(rowInfo1);
                        this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowEventArgs>(EventDispatcher.UserAddedRow, (object)this.ViewTemplate, args3);
                        this.addedRow = (GridViewRowInfo)null;
                    }
                    else
                    {
                        this.addedRow = rowInfo1;
                    }
                    this.deferUserAddedRow = false;
                    if (this.moveToLastRow)
                    {
                        rowInfo1.IsCurrent = true;
                        this.moveToLastRow = false;
                    }
                    else
                    {
                        this.ViewTemplate.MasterTemplate.CurrentRow = (GridViewRowInfo)this.ViewInfo.TableAddNewRow;
                    }
                }
                else
                {
                    if (this.boundRow != null || this.ViewTemplate.ListSource.Count > count)
                    {
                        ((ICancelAddNew)this.ViewTemplate.ListSource).CancelNew(this.ViewTemplate.ListSource.Count - 1);
                    }
                    this.ViewTemplate.EndUpdate(false);
                }
            }
            catch (Exception ex)
            {
                if (this.boundRow != null || this.ViewTemplate.ListSource.Count > count)
                {
                    ((ICancelAddNew)this.ViewTemplate.ListSource).CancelNew(this.ViewTemplate.ListSource.Count - 1);
                }
                this.ViewTemplate.EndUpdate(false);
                this.ViewTemplate.SetError(new GridViewCellCancelEventArgs((GridCellElement)null, (IInputEditor)null), ex);
                return((GridViewRowInfo)null);
            }
            finally
            {
                this.boundRow          = (GridViewRowInfo)null;
                this.newRowInitialized = false;
                this.IsModified        = false;
                this.ClearCache();
                this.changedColumns.Clear();
                this.InvalidateRow();
                this.ViewTemplate.Rows.addingThroughUI = false;
                if (this.ViewTemplate != null && this.ViewTemplate.ListSource != null)
                {
                    this.ViewTemplate.ListSource.CreateATransactionForEveryValueSetting = true;
                }
                if (rowInfo1 != null)
                {
                    rowInfo1.AddingNewDataRow = false;
                }
                if (this.ViewInfo.ParentRow != null && this.ViewInfo.SummaryRows.Count > 0)
                {
                    ++this.ViewInfo.summaryValueVersion;
                    this.ViewTemplate.MasterTemplate.SynchronizationService.DispatchEvent(new GridViewEvent((object)this.ViewTemplate, (object)this, new object[1]
                    {
                        (object)new DataViewChangedEventArgs(ViewChangedAction.DataChanged, (IList)null)
                    }, new GridViewEventInfo(KnownEvents.ViewChanged, GridEventType.Both, GridEventDispatchMode.Send)));
                }
            }
            return(rowInfo1);
        }