Esempio n. 1
0
 public static bool IsNewRowVisible(GridViewNewRowInfo newRow)
 {
     if (newRow.IsVisible && !newRow.ViewInfo.ViewTemplate.MasterTemplate.GridReadOnly && !newRow.ViewInfo.ViewTemplate.ReadOnly)
     {
         return(newRow.ViewInfo.ViewTemplate.AllowAddNewRow);
     }
     return(false);
 }
Esempio n. 2
0
        protected override bool ProcessDownKey(KeyEventArgs keys)
        {
            GridViewNewRowInfo currentRow = (GridViewNewRowInfo)this.GridViewElement.CurrentRow;

            if (this.GridViewElement.Template.AddNewRowPosition == SystemRowPosition.Bottom)
            {
                return(false);
            }
            return(base.ProcessDownKey(keys));
        }
Esempio n. 3
0
 protected virtual void InitializeTableAddNewRow()
 {
     if (this.tableAddNewRow != null)
     {
         return;
     }
     this.tableAddNewRow = this.CreateAddNewRow();
     this.systemRows.Add((GridViewSystemRowInfo)this.tableAddNewRow);
     this.TableAddNewRow.SuspendPropertyNotifications();
     this.SynchronizeNewRowPosition();
     this.TableAddNewRow.ResumePropertyNotifications();
 }
Esempio n. 4
0
        private bool FinishEditingOperation()
        {
            bool               flag1              = false;
            GridViewRowInfo    currentRow         = this.gridViewElement.Template.CurrentRow;
            GridViewNewRowInfo gridViewNewRowInfo = currentRow as GridViewNewRowInfo;

            if (gridViewNewRowInfo != null && gridViewNewRowInfo.Validated)
            {
                gridViewNewRowInfo.Validated = false;
                return(true);
            }
            bool flag2 = gridViewNewRowInfo != null;

            if (currentRow != null && (currentRow.IsAttached || flag2) && this.RaiseRowValidatingEvent(currentRow))
            {
                return(flag1);
            }
            if (currentRow != null && (currentRow.IsAttached || flag2))
            {
                this.RaiseRowValidatedEvent(currentRow);
            }
            bool flag3 = true;

            if (flag2 && !currentRow.IsModified && (gridViewNewRowInfo.ViewTemplate != null && gridViewNewRowInfo.ViewTemplate.ListSource != null))
            {
                gridViewNewRowInfo.ViewTemplate.ListSource.CreateATransactionForEveryValueSetting = true;
            }
            if (currentRow == null || !currentRow.IsModified)
            {
                return(flag3);
            }
            this.GridViewElement.Template.SynchronizationService.RemoveListener((IGridViewEventListener)this);
            try
            {
                if (flag2)
                {
                    flag3 = currentRow.CallOnEndEdit();
                }
                if (flag3)
                {
                    currentRow.IsModified = false;
                }
                return(flag3);
            }
            finally
            {
                this.GridViewElement.Template.SynchronizationService.AddListener((IGridViewEventListener)this);
            }
        }
Esempio n. 5
0
        protected override bool ProcessEscapeKey(KeyEventArgs keys)
        {
            if (this.GridViewElement.IsInEditMode)
            {
                return(base.ProcessEscapeKey(keys));
            }
            GridViewNewRowInfo currentRow = (GridViewNewRowInfo)this.GridViewElement.CurrentRow;

            currentRow.CancelAddNewRow();
            if (currentRow.ViewTemplate.DataView.CurrentItem != null)
            {
                currentRow.ViewTemplate.DataView.CurrentItem.IsCurrent = true;
            }
            if (currentRow.ViewInfo != null && currentRow.ViewInfo.ChildRows.Count == 0)
            {
                currentRow.IsCurrent = false;
            }
            return(true);
        }
Esempio n. 6
0
        protected override bool ProcessEnterKey(KeyEventArgs keys)
        {
            bool isInEditMode = this.GridViewElement.IsInEditMode;

            if (!isInEditMode && this.GridViewElement.BeginEditMode == RadGridViewBeginEditMode.BeginEditOnEnter)
            {
                return(this.GridViewElement.BeginEdit());
            }
            if (isInEditMode)
            {
                RadTextBoxEditor activeEditor = this.EditorManager.ActiveEditor as RadTextBoxEditor;
                if (activeEditor != null && activeEditor.AcceptsReturn)
                {
                    return(false);
                }
            }
            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.None)
            {
                if (isInEditMode)
                {
                    this.GridViewElement.CloseEditor();
                }
                return(true);
            }
            GridViewNewRowInfo currentRow1 = (GridViewNewRowInfo)this.GridViewElement.CurrentRow;

            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToNextCell)
            {
                bool flag = !this.IsInEditMode;
                if (isInEditMode)
                {
                    if (this.IsOnLastCell())
                    {
                        currentRow1?.DeferUserAddedRow();
                        flag = this.GridViewElement.EndEdit();
                        if (currentRow1.RowPosition == SystemRowPosition.Bottom)
                        {
                            this.GridViewElement.UpdateLayout();
                            currentRow1.EnsureVisible();
                            this.Navigator.SelectFirstColumn();
                            flag = false;
                        }
                    }
                    else
                    {
                        flag = this.GridViewElement.CloseEditor();
                    }
                }
                if (flag)
                {
                    this.Navigator.SelectNextColumn();
                }
                currentRow1?.RaiseUserAddedRow();
                if (isInEditMode && this.GridViewElement.CurrentRow is GridViewNewRowInfo && this.GridViewElement.BeginEditMode != RadGridViewBeginEditMode.BeginEditProgrammatically)
                {
                    return(this.GridViewElement.BeginEdit());
                }
                return(false);
            }
            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToLastAddedRow)
            {
                currentRow1.MoveToLastRow = true;
            }
            if (!isInEditMode)
            {
                RowValidatingEventArgs args = new RowValidatingEventArgs((GridViewRowInfo)currentRow1);
                this.MasterTemplate.EventDispatcher.RaiseEvent <RowValidatingEventArgs>(EventDispatcher.RowValidating, (object)this, args);
                if (args.Cancel)
                {
                    return(false);
                }
                currentRow1?.DeferUserAddedRow();
                currentRow1.EndAddNewRow();
            }
            else
            {
                currentRow1?.DeferUserAddedRow();
                if (!this.GridViewElement.EndEdit())
                {
                    return(false);
                }
            }
            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToNextRow)
            {
                if (currentRow1.PinPosition == PinnedRowPosition.Bottom)
                {
                    this.EnsureLastRowVisible(currentRow1);
                }
                else if (currentRow1.RowPosition == SystemRowPosition.Bottom)
                {
                    this.GridViewElement.UpdateLayout();
                    currentRow1.EnsureVisible();
                }
                else
                {
                    EventDispatcher eventDispatcher = currentRow1.ViewTemplate.MasterTemplate.EventDispatcher;
                    eventDispatcher.SuspendEvent(EventDispatcher.CellValidating);
                    eventDispatcher.SuspendEvent(EventDispatcher.CellValidated);
                    eventDispatcher.SuspendEvent(EventDispatcher.RowValidating);
                    eventDispatcher.SuspendEvent(EventDispatcher.RowValidated);
                    GridViewRowInfo currentRow2;
                    GridViewRowInfo currentRow3;
                    do
                    {
                        currentRow2 = ((BaseGridNavigator)this.Navigator).MasterTemplate.CurrentRow;
                        this.Navigator.SelectNextRow(1);
                        currentRow3 = ((BaseGridNavigator)this.Navigator).MasterTemplate.CurrentRow;
                    }while (!(currentRow3 is GridViewDataRowInfo) && !(currentRow3 is GridViewGroupRowInfo) && currentRow3 != currentRow2);
                    eventDispatcher.ResumeEvent(EventDispatcher.CellValidating);
                    eventDispatcher.ResumeEvent(EventDispatcher.CellValidated);
                    eventDispatcher.ResumeEvent(EventDispatcher.RowValidating);
                    eventDispatcher.ResumeEvent(EventDispatcher.RowValidated);
                }
            }
            currentRow1?.RaiseUserAddedRow();
            return(false);
        }
Esempio n. 7
0
 private void EnsureLastRowVisible(GridViewNewRowInfo newRowInfo)
 {
     this.GetLastScrollableRow((GridViewRowInfo)newRowInfo)?.EnsureVisible();
 }
        public GridViewRowInfo AddNewRow(GridViewNewRowInfo newRow)
        {
            GridViewRowInfo        parent          = newRow.Parent as GridViewRowInfo;
            PropertyDescriptor     descriptor      = ListBindingHelper.GetListItemProperties(parent.DataBoundItem).Find(this.relation.ChildColumnNames[0], true);
            List <GridViewRowInfo> cachedChildRows = this.GetCachedChildRows(parent.DataBoundItem, descriptor);

            if (descriptor == null)
            {
                return((GridViewRowInfo)null);
            }
            IList list = descriptor.GetValue(parent.DataBoundItem) as IList;

            if (list != null)
            {
                this.SuspendNotifications();
                object          instance        = Activator.CreateInstance(ListBindingHelper.GetListItemType((object)list));
                GridViewRowInfo gridViewRowInfo = this.Template.Rows.NewRow();
                ((IDataItem)gridViewRowInfo).DataBoundItem = instance;
                gridViewRowInfo.SetParent(parent);
                foreach (GridViewColumn column in (Collection <GridViewDataColumn>)newRow.ViewTemplate.Columns)
                {
                    if (column.IsVisible && !column.ReadOnly && newRow.Cells[column.FieldName].Value != null)
                    {
                        gridViewRowInfo[column] = newRow.Cells[column.FieldName].Value;
                    }
                }
                list.Add(instance);
                cachedChildRows.Add(gridViewRowInfo);
                this.ResumeNotifications();
                return(gridViewRowInfo);
            }
            object obj = descriptor.GetValue(parent.DataBoundItem);

            if (obj == null)
            {
                return((GridViewRowInfo)null);
            }
            System.Type type = obj.GetType();
            if (!type.IsGenericType || type.IsGenericTypeDefinition)
            {
                return((GridViewRowInfo)null);
            }
            MethodInfo method = type.GetMethod("Add");

            if ((object)method == null)
            {
                return((GridViewRowInfo)null);
            }
            this.SuspendNotifications();
            object          instance1        = Activator.CreateInstance(ListBindingHelper.GetListItemType((object)list));
            GridViewRowInfo gridViewRowInfo1 = this.Template.Rows.NewRow();

            ((IDataItem)gridViewRowInfo1).DataBoundItem = instance1;
            gridViewRowInfo1.SetParent(parent);
            foreach (GridViewColumn column in (Collection <GridViewDataColumn>)newRow.ViewTemplate.Columns)
            {
                if (column.IsVisible && !column.ReadOnly && newRow.Cells[column.FieldName].Value != null)
                {
                    gridViewRowInfo1[column] = newRow.Cells[column.FieldName].Value;
                }
            }
            method.Invoke(obj, new object[1] {
                instance1
            });
            cachedChildRows.Add(gridViewRowInfo1);
            this.ResumeNotifications();
            return(gridViewRowInfo1);
        }