Example #1
0
    public RowState Clone()
    {
      RowState rowState = new RowState();

      rowState.m_itemValidationError = m_itemValidationError;
      rowState.m_isDirty = m_isDirty;

      return rowState;
    }
Example #2
0
        public RowState Clone()
        {
            RowState rowState = new RowState();

            rowState.m_itemValidationError = m_itemValidationError;
            rowState.m_isDirty             = m_isDirty;

            return(rowState);
        }
Example #3
0
    // Used to initialize/clear Column.CurrentRowInEditionCellState for each cell in the row passed as parameter
    internal void UpdateCurrentRowInEditionCellStates( Row newCurrentItemContainer, object newCurrentItemInEdition )
    {
      if( newCurrentItemInEdition != m_currentItemInEdition )
      {
        Row currentRowInEdition = null;

        if( m_currentItemInEdition != null )
        {
          // Get the container for m_currentItemInEdition
          currentRowInEdition = Row.FromContainer( this.CurrentContext.GetContainerFromItem( m_currentItemInEdition ) );

          if( newCurrentItemInEdition != null )
          {
            if( ( currentRowInEdition != null ) && ( currentRowInEdition.IsBeingEdited ) )
              throw new InvalidOperationException( "An attempt was made to place a row in edit mode while another row is being edited." );
          }
        }

        // The newCurrentItemContainer is null
        if( newCurrentItemContainer == null )
        {
          if( currentRowInEdition != null )
          {
            // We must clear the edition state of the old Row in edition
            foreach( Cell cell in currentRowInEdition.CreatedCells )
            {
              ColumnBase parentColumn = cell.ParentColumn;

              if( parentColumn == null )
                continue;

              parentColumn.CurrentRowInEditionCellState = null;
            }
          }
        }

        m_currentItemInEdition = newCurrentItemInEdition;
        m_currentRowInEditionState = new RowState();

        this.UpdateIsBeingEdited();
      }

      // It may occur that the newCurrentItemInEdition was set for a
      // Container that is currently out of view, so the newCurrentItemContainer
      // was null at this time. We must then ensure the CellStates are 
      // create for the newCurrentItemContainer when not null even if 
      // newCurrentItemInEdition == m_currentItemInEdition
      if( newCurrentItemContainer != null )
      {
        foreach( Cell cell in newCurrentItemContainer.CreatedCells )
        {
          ColumnBase parentColumn = cell.ParentColumn;

          if( parentColumn == null )
            continue;

          CellState cellState = new CellState();
          cellState.SetContentBeforeRowEdition( cell.Content );

          parentColumn.CurrentRowInEditionCellState = cellState;
        }
      }
    }
Example #4
0
    private void RestoreEditionState( RowState savedState, ColumnBase currentColumn )
    {
      if( savedState == null )
        return;

      savedState = savedState.Clone();

      Dictionary<ColumnBase, CellState> cachedCellStates = new Dictionary<ColumnBase, CellState>();

      foreach( Cell cell in this.CreatedCells )
      {
        ColumnBase parentColumn = cell.ParentColumn;

        if( parentColumn == null )
          continue;

        var currentRowInEditionCellState = parentColumn.CurrentRowInEditionCellState;

        if( currentRowInEditionCellState != null )
          cachedCellStates.Add( parentColumn, currentRowInEditionCellState.Clone() );
      }

      try
      {
        this.BeginEdit();
      }
      catch( DataGridException )
      {
        // We swallow exception if it occurs because of a validation error or Cell was read-only or
        // any other GridException.
      }

      if( this.IsBeingEdited )
      {
        this.SetValidationError( savedState.ItemValidationError );

        this.SetIsDirty( savedState.IsDirty );

        foreach( Cell cell in this.CreatedCells )
        {
          ColumnBase parentColumn = cell.ParentColumn;
          CellState cachedCellState;

          if( cachedCellStates.TryGetValue( parentColumn, out cachedCellState ) )
            parentColumn.CurrentRowInEditionCellState = cachedCellState;

          cell.RestoreEditionState( currentColumn );
        }
      }
    }