Intersoft ClientUI Documentation
RejectRowCommand Property
See Also  Send Feedback
Intersoft.Client.UI.Data Namespace > UXGridView Class : RejectRowCommand Property






Gets or sets command that will be invoked when row changes is rejected.

Syntax

Visual Basic (Declaration) 
<TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")>
<CategoryAttribute("Action")>
Public Property RejectRowCommand As ICommand
Visual Basic (Usage)Copy Code
Dim instance As UXGridView
Dim value As ICommand
 
instance.RejectRowCommand = value
 
value = instance.RejectRowCommand
C# 
[TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")]
[CategoryAttribute("Action")]
public ICommand RejectRowCommand {get; set;}
Delphi 
public read-write property RejectRowCommand: ICommand; 
JScript 
TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")
CategoryAttribute("Action")
public function get,set RejectRowCommand : ICommand
Managed Extensions for C++ 
[TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")]
[CategoryAttribute("Action")]
public: __property ICommand* get_RejectRowCommand();
public: __property void set_RejectRowCommand( 
   ICommand* value
);
C++/CLI 
[TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")]
[CategoryAttribute("Action")]
public:
property ICommand^ RejectRowCommand {
   ICommand^ get();
   void set (    ICommand^ value);
}

Example

The following code example shows how to define and bind the editing commands from ViewModel to UXGridView.

View Model Copy Code
using System.Collections;
using Intersoft.Client.Framework;
using Intersoft.Client.Framework.Input;
using Intersoft.Client.UI.Data;
using UXGridView.Samples.ModelServices;

namespace UXGridView.Samples.ViewModels
{
    public class ServerEditingViewModel : ViewModelBase
    {
        public ServerEditingViewModel()
            : base()
        {
            this.Manager = new NorthwindDomainContext();
            this.QueryDescriptor = new QueryDescriptor();
            
            this.ExportCommand = new DelegateCommand(ExecuteExportCommand);
            this.DeleteRowCommand = new DelegateCommand(ExecuteDeleteRow);
            this.InsertRowCommand = new DelegateCommand(ExecuteInsertRow);
            this.PrepareNewRowCommand = new DelegateCommand(ExecutePrepareNewRow);
            this.UpdateCellCommand = new DelegateCommand(ExecuteUpdateCell);
            this.UpdateRowCommand = new DelegateCommand(ExecuteUpdateRow);
            this.RejectRowCommand = new DelegateCommand(ExecuteRejectRow);
            this.RejectChangesCommand = new DelegateCommand(ExecuteRejectChanges);
            this.SaveChangesCommand = new DelegateCommand(ExecuteSaveChanges);
            this.ValidateRowCommand = new DelegateCommand(ExecuteValidateRow);
        }

        #region Fields

        private bool _hasChanges;
        private bool _isBusy;
        private bool _isRefreshed;
        private object _newProduct;
        private IEnumerable _products;
        private QueryDescriptor _queryDescriptor;
        
        #endregion

        #region Properties

        private NorthwindDomainContext Manager { get; set; }

        public IEnumerable Products
        {
            get { return this._products; }
            set
            {
                if (this._products != value)
                {
                    this._products = value;
                    this.OnPropertyChanged("Products");
                }
            }
        }

        public QueryDescriptor QueryDescriptor
        {
            get
            {
                return this._queryDescriptor;
            }
            set
            {
                if (this._queryDescriptor != value)
                {
                    if (this._queryDescriptor != null)
                        this._queryDescriptor.QueryChanged -= new System.EventHandler(OnQueryChanged);

                    this._queryDescriptor = value;
                    this._queryDescriptor.QueryChanged += new System.EventHandler(OnQueryChanged);

                    this.OnPropertyChanged("QueryDescriptor");
                }
            }
        }

        #endregion

        #region Selection and Editing Properties

        public object NewProduct
        {
            get { return this._newProduct; }
            set
            {
                if (this._newProduct != value)
                {
                    this._newProduct = value;
                    this.OnPropertyChanged("NewProduct");
                }
            }
        }      

        public bool IsBusy
        {
            get { return this._isBusy; }
            set
            {
                if (this._isBusy != value)
                {
                    this._isBusy = value;
                    this.OnPropertyChanged("IsBusy");
                }
            }
        }

        public bool IsRefreshed
        {
            get { return this._isRefreshed; }
            set
            {
                if (this._isRefreshed != value)
                {
                    this._isRefreshed = value;
                    this.OnPropertyChanged("IsRefreshed");
                }
            }
        }

        public bool HasChanges
        {
            get { return _hasChanges; }
            set
            {
                if (_hasChanges != value)
                {
                    _hasChanges = value;
                    OnPropertyChanged("HasChanges");
                }
            }
        }

        #endregion

        #region Commands

        public DelegateCommand DeleteRowCommand { get; set; }
        public DelegateCommand InsertRowCommand { get; set; }
        public DelegateCommand PrepareNewRowCommand { get; set; }
        public DelegateCommand UpdateCellCommand { get; set; }
        public DelegateCommand UpdateRowCommand { get; set; }
        public DelegateCommand RejectRowCommand { get; set; }
        public DelegateCommand RejectChangesCommand { get; set; }
        public DelegateCommand SaveChangesCommand { get; set; }
        public DelegateCommand ValidateRowCommand { get; set; }

        #endregion

        #region Methods

        public void SaveChanges()
        {

        }

        public void ExecuteDeleteRow(object parameter)
        {

        }

        public void ExecuteInsertRow(object parameter)
        {

        }

        public void ExecutePrepareNewRow(object parameter)
        {
            
        }

        public void ExecuteUpdateCell(object parameter)
        {
            
        }

        public void ExecuteValidateRow(object parameter)
        {
            
        }

        public void ExecuteUpdateRow(object parameter)
        {
            
        }

        public void ExecuteRejectRow(object parameter)
        {
            
        }

        public void ExecuteRejectChanges(object parameter)
        {
            
        }

        public void ExecuteSaveChanges(object parameter)
        {
            
        }

        public virtual void LoadProducts()
        {
            if (Intersoft.Client.Framework.ISControl.IsInDesignModeStatic)
                return;

            var query = this.Manager.GetProductsQuery().OrderBy(p => p.ProductID).Parse(this.QueryDescriptor);
            query.IncludeTotalCount = true;

            this.Manager.Load(
               query,
               op =>
               {
                   if (op.IsComplete)
                   {
                       this.Products = new Intersoft.Client.Data.ComponentModel.PagedCollectionView(op.Entities);
                       this.QueryDescriptor.PageDescriptor.TotalItemCount = op.TotalEntityCount;
                   }
                   else
                   {
                       MessageBox.Show(op.Error.ToString());
                   }
               },

               true);
        }

        private void OnQueryChanged(object sender, System.EventArgs e)
        {            
            this.LoadProducts();
        }

        #endregion
    }
}
View Copy Code
<Intersoft:UXGridView
    AutoGenerateColumns="False" QueryOperation="Server"
    CanUserPage="True" PageSize="20"
    RowHeaderVisibility="Visible"
    IsBusy="{Binding IsBusy, Mode=TwoWay}"
    IsRefreshed="{Binding IsRefreshed, Mode=TwoWay}"
    ItemsSource="{Binding Products}"
    SortDescriptors="{Binding QueryDescriptor.SortDescriptors, Mode=TwoWay}"
    PageDescriptor="{Binding QueryDescriptor.PageDescriptor}"
    GroupFootersVisibility="Visible" GroupByBoxVisibility="Visible"
    CanUserAddRows="True"
    CanUserDeleteRows="True"
    CanUserEditRows="True"
    NewItem="{Binding NewProduct, Mode=TwoWay}"
    ValidateRowCommand="{Binding ValidateRowCommand}"
    InsertRowCommand="{Binding InsertRowCommand}"
    DeleteRowCommand="{Binding DeleteRowCommand}"
    PrepareNewRowCommand="{Binding PrepareNewRowCommand}"
    UpdateCellCommand="{Binding UpdateCellCommand}"
    UpdateRowCommand="{Binding UpdateRowCommand}"
    SaveChangesCommand="{Binding SaveChangesCommand}"
    RejectRowCommand="{Binding RejectRowCommand}"
    RejectChangesCommand="{Binding RejectChangesCommand}"
    HasChanges="{Binding HasChanges}">

    <Intersoft:UXGridView.GroupDescriptors>
        <Intersoft:UXGridViewGroupDescriptor PropertyName="CategoryID"/>
    </Intersoft:UXGridView.GroupDescriptors>

    <Intersoft:UXGridView.Columns>
        <Intersoft:UXGridViewTextColumn Header="Category ID" Binding="{Binding CategoryID}"/>
        <Intersoft:UXGridViewTextColumn Header="Product ID" Binding="{Binding ProductID}"
                                            IsReadOnly="True" Aggregate="Count" FooterFormatString="Count = {0}"/>
        <Intersoft:UXGridViewTextColumn Header="Product Name" Binding="{Binding ProductName}"/>
        <Intersoft:UXGridViewTextColumn Header="Units In Stock" Binding="{Binding UnitsInStock}" 
                                            Aggregate="Max" FooterFormatString="Max = {0}"/>
        <Intersoft:UXGridViewTextColumn Header="Unit Price" Binding="{Binding UnitPrice}" 
                                            Aggregate="Avg" FooterFormatString="Avg = {0:n2}"/>
        <Intersoft:UXGridViewTextColumn Header="Units On Order" Binding="{Binding UnitsOnOrder}"
                                            Aggregate="Min" FooterFormatString="Min = {0}"/>
        <Intersoft:UXGridViewTextColumn Header="Quantity Per Unit" Binding="{Binding QuantityPerUnit}"/>
    </Intersoft:UXGridView.Columns>
</Intersoft:UXGridView>

Remarks

To handle the CUD operation, UXGridView provides several command-related properties that you can bind to your ViewModel to execute a method depending on the actions. These command-related properties are listed as follows:

  • PrepareNewRowCommand
    Called when you begin edit at the NewRow element. Used to initialized the NewItem.
  • ValidateRowCommand
    Validate the row before the row is committed.
  • InsertRowCommand
    Called when a new row is committed. You can directly save the changes and/or refresh the UXGridView if necessary.
  • UpdateCellCommand
    Called when the cell is committed.
  • UpdateRowCommand
    Called when an existing row is committed. You can directly save the changes and/or refresh the UXGridView if necessary.
  • DeleteRowCommand
    Called when a row is deleted. You can directly save the changes and / or refresh the UXGridView if necessary.
  • RejectRowCommand
    Called when the changes in the row is cancelled. This command is used to reject the changes in the data entity if required (such as in DevForce).
  • SaveChangesCommand
    Called when the save changes command is executed. You handle this command to save all the pending changes made in the UXGridView.
  • RejectChangesCommand
    Called when the reject changes command is executed. You handle this command to reject all the pending changes made in the UXGridView.

You need to bind these command properties to your ViewModel and handle each of the action. Beside these command, UXGridView also provide HasChanges that you can use to determine whether there are existing changes in the data.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.