Intersoft.Client.UI.Data Namespace > UXGridView Class : RejectRowCommand Property |
<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
Dim instance As UXGridView Dim value As ICommand instance.RejectRowCommand = value value = instance.RejectRowCommand
[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;}
[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); }
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:
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.
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> |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2