I am using gridview control for WPF. I have setted the validation condition for a column 'Capacity' for editting. The validation condition is that if you enter the '0' value for the column 'Capacity', one message box should be visible. The message box contains option 'Yes' and 'No'. If user clicks option 'Yes', then replace the entered '0' with '0.001'. So, how to set the editted value of cell from '0' to '0.001' dynamically.? I have tried using e.NewData = "0.001" in CellEditEnded method, but failed to do. Please help. It is urgent.
10 Answers, 1 is accepted
You can use CellValidating event. There is an EditingElement property of the event args which you can use to change the value, other way is to update data source directly. I'm attaching a sample project which demonstrates the first approach.
All the best,
Nedyalko Nikolov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi Nedyalko Nikolov,
This is bhaskar,Rajeevs team mate.We are trying to implement the suggested solution in version 2009.2.813.35. we are not able to fix the issue.if we are using latest version dlls 2009.3.116.35 issue got resolved but facing problem with old code,it is not supporting some of the old methods.
void ColumnGroup_Loaded(object sender, RoutedEventArgs e)
{
this.parentGrid = this.ParentOfType<RadGridView>();
this.parentGrid.ItemsControl.VirtualizingPanel.ScrollOwner.HorizontalScrollChanged += new EventHandler<System.Windows.Controls.Primitives.ScrollEventArgs>(ScrollOwner_HorizontalScrollChanged);
foreach (Telerik.Windows.Controls.GridViewColumn column in this.parentGrid.Columns)
{
column.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(column_PropertyChanged);
}
AlignToColumns();
}
in that code parentgrid is not supporting ItemsControl .
We are facing problems with backward compatabilty.could you please suggest what was the solution for this.because we dont want to miss that functionality.
Regards,
BHASKAR
You can replace your code with the following one:
your code:
this
.parentGrid.ItemsControl.VirtualizingPanel.ScrollOwner.HorizontalScrollChanged...
new
code:
GridViewVirtualizingPanel panel =
this
.parentGrid.ChildrenOfType<GridViewVirtualingPanel>[0];
if
(panel !=
null
)
{
panel.ScrollOwner.HorizontalScrollChanged ...
}
Hope this helps.
All the best,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thanks for the reply.But if i am using your code in my application it is not recognizing the methods.
My code:
this.parentGrid.ItemsControl.VirtualizingPanel.ScrollOwner.HorizontalScrollChanged += new EventHandler<System.Windows.Controls.Primitives.ScrollEventArgs>(ScrollOwner_HorizontalScrollChanged);
this code id not working with version Telerik 2009.3.1314.35
Your Code:
Iam using Version: Telerik 2009.3.1314.35
GridViewVirtualizingPanel panel = this.parentGrid.ChildrenOfType<GridViewVirtualingPanel>[0];
if (panel != null)
{
panel.ScrollOwner.HorizontalScrollChanged+= new
}
The underlined methods are not recognising in my application
Please Provide solution for this ASAP..Thanks in Advance.
Regards,
BHASKAR.
Since ChildrenOfType<> is extension method you need to add using Telerik.Windows.Controls.
Sincerely yours,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I have used using telerik.windows.controls ,Still Iam facing the problem,not able to recognize the Bold Items in the code.The panel.scrollowner is not finding the event HorizontalScrollChanged ,Could you please suggest what i need to do to fix this.Please have a look on my code.
#region Events
void ColumnGroup_Loaded(object sender, RoutedEventArgs e)
{
this.parentGrid = this.ParentOfType<RadGridView>();
//this.parentGrid.ItemsControl.VirtualizingPanel.ScrollOwner.HorizontalScrollChanged += new EventHandler<System.Windows.Controls.Primitives.ScrollEventArgs>(ScrollOwner_HorizontalScrollChanged);
GridViewVirtualizingPanel panel = this.parentGrid.ChildrenOfType<GridViewVirtualizingPanel>[0];
if (panel != null)
{
panel.ScrollOwner.HorizontalScrollChanged +=
}
foreach (Telerik.Windows.Controls.GridViewColumn column in this.parentGrid.Columns)
{
column.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(column_PropertyChanged);
}
AlignToColumns();
}
void ScrollOwner_HorizontalScrollChanged(object sender, System.Windows.Controls.Primitives.ScrollEventArgs e)
{
this.horizontalScrollOffset = e.NewValue;
this.AlignToColumns();
}
#endregion
Thanks&Regards,
BHASKAR
This class is in Telerik.Windows.Controls.GridView namespace.
Sincerely yours,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Hi Vlad,
I have referenced All the below namespaces in my class
using Telerik.Windows;
using Telerik.Windows.Data;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Controls;
Still i am facing the same issue.
Thanks,
BHASKAR
Hi Vlad,
I was tried to find the way to get the code to run,but iam not.could please have a look on my code and suggest the methods which i need to use when i refer latest dlls(Telerik 2009.3.1314.35).These methods are working fine when i refer (Telerik 2009.2.813.35).
Thanks in Advance.
Regards,
BHASKAR.
#region Assembly Reference
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
#endregion
namespace NAMESPACE
{
/// <summary>
/// Interaction logic for ColumnGroupingView.xaml
/// </summary>
public partial class ColumnGroupingView : UserControl
{
#region Constructor
public ColumnGroupingView(Telerik.Windows.Controls.GridViewColumn firstColumn, Telerik.Windows.Controls.GridViewColumn lastColumn, string caption)
{
InitializeComponent();
this.FirstColumn = firstColumn;
this.LastColumn = lastColumn;
this.Caption = caption;
this.HorizontalAlignment = HorizontalAlignment.Left;
this.VerticalAlignment = VerticalAlignment.Top;
this.Loaded += new RoutedEventHandler(ColumnGroup_Loaded);
this.Indent = 5;
this.SetValue(Grid.ColumnProperty, 2);
}
#endregion
#region Variable and Property
public static readonly DependencyProperty CaptionProperty =
DependencyProperty.Register("Caption", typeof(string), typeof(ColumnGroupingView), new PropertyMetadata(String.Empty, CaptionChanged));
public string Caption
{
get
{
return (string)this.GetValue(CaptionProperty);
}
set
{
this.SetValue(CaptionProperty, value);
}
}
public double Indent { get; set; }
public Telerik.Windows.Controls.GridViewColumn FirstColumn { get; set; }
public Telerik.Windows.Controls.GridViewColumn LastColumn { get; set; }
private RadGridView parentGrid;
double horizontalScrollOffset;
#endregion
#region Events
void ColumnGroup_Loaded(object sender, RoutedEventArgs e)
{
this.parentGrid = this.ParentOfType<RadGridView>();
//Not able to use this method
this.parentGrid.ItemsControl.VirtualizingPanel.ScrollOwner.HorizontalScrollChanged += new EventHandler<System.Windows.Controls.Primitives.ScrollEventArgs>(ScrollOwner_HorizontalScrollChanged);
foreach (Telerik.Windows.Controls.GridViewColumn column in this.parentGrid.Columns)
{
column.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(column_PropertyChanged);
}
AlignToColumns();
}
void ScrollOwner_HorizontalScrollChanged(object sender, System.Windows.Controls.Primitives.ScrollEventArgs e)
{
this.horizontalScrollOffset = e.NewValue;
this.AlignToColumns();
}
#endregion
#region Methods
static void CaptionChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
((ColumnGroupingView)sender).CaptionTextBlock.Text = (string)args.NewValue;
}
void column_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "ActualWidth")
this.AlignToColumns();
}
private void AlignToColumns()
{
double startPosition = 0;
double endPosition = 0;
double offset = 2;
foreach (Telerik.Windows.Controls.GridViewColumn column in this.parentGrid.Columns)
{
if (column == this.FirstColumn)
{
startPosition = offset;
}
offset += column.ActualWidth;
if (column == this.LastColumn)
endPosition = offset;
}
this.Margin = new Thickness(startPosition + Indent - horizontalScrollOffset, 0, 0, 0);
this.Width = endPosition - startPosition;
}
#endregion
}
}
Indeed with the new version type of the ScrollOwner is changed from GridViewScrollViewer to ScrollViewer therefore there is no HorizontalScrollChanged event. You can use ScrollChanged event instead.
I hope this will help.
Greetings,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.