This question is locked. New answers and comments are not allowed.
Hi
I am working on a project that requires the GridView to be editable.
Whenever the user update the retail price, the wholesale price column and margin column will be recalculated.
Is there anyway I can set formula among different columns?
Best regards
David Lau
I am working on a project that requires the GridView to be editable.
Whenever the user update the retail price, the wholesale price column and margin column will be recalculated.
Is there anyway I can set formula among different columns?
Best regards
David Lau
8 Answers, 1 is accepted
0
Hi David,
Please check this blog post for more info about how to achieve this:
http://blogs.telerik.com/pavelpavlov/posts/10-01-28/calculated_column_in_radgridview_for_silverlight_math_expressions.aspx
Greetings,
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.
Please check this blog post for more info about how to achieve this:
http://blogs.telerik.com/pavelpavlov/posts/10-01-28/calculated_column_in_radgridview_for_silverlight_math_expressions.aspx
Greetings,
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.
0
Stefan
Top achievements
Rank 1
answered on 08 Jun 2010, 03:16 PM
Hi,
It work´s fine, but what´s about when the Grid is editable (IsReadOnly-Property=false). The value in theTotal-Column is not updated automatically. Is there any method like "ReCalc" to update the values in the Total-Column after the user changes a value in the Count or Price - column. I tried the method "Rebind" when the event CellEditEnded was fired, but it doesn´t work.
Please help I need a solution for a presentation.
Thank´s in advance.
With best regards
Stefan
It work´s fine, but what´s about when the Grid is editable (IsReadOnly-Property=false). The value in theTotal-Column is not updated automatically. Is there any method like "ReCalc" to update the values in the Total-Column after the user changes a value in the Count or Price - column. I tried the method "Rebind" when the event CellEditEnded was fired, but it doesn´t work.
Please help I need a solution for a presentation.
Thank´s in advance.
With best regards
Stefan
0
Hi Stefan,
Kind regards,
Pavel Pavlov
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.
Please try calling RadGridView1.CalculateAggregates() method after updating the values.
Kind regards,
Pavel Pavlov
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.
0
Stefan
Top achievements
Rank 1
answered on 09 Jun 2010, 10:06 AM
Hi Pavel,
I fired the CalculateAggregates-Method in CellEditEnded-Event but it doesn´t work, the cell content is still the same.
When I call the Rebind-Method (later for example per Button-Click-Event) the cell content is updated and ok.
But it´s not useful to fire the Rebind-Method in CellEditEnded (this will triggers a infinite loop).
Kind regards
Stefan
I fired the CalculateAggregates-Method in CellEditEnded-Event but it doesn´t work, the cell content is still the same.
When I call the Rebind-Method (later for example per Button-Click-Event) the cell content is updated and ok.
But it´s not useful to fire the Rebind-Method in CellEditEnded (this will triggers a infinite loop).
Kind regards
Stefan
0
Hello Stefan,
I believe In your scenario it would be bettter to perform calculations in the data layer as demonstrated in the attached project.
Let me know in case this does not work for you.
All the best,
Pavel Pavlov
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 believe In your scenario it would be bettter to perform calculations in the data layer as demonstrated in the attached project.
Let me know in case this does not work for you.
All the best,
Pavel Pavlov
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.
0
Stefan
Top achievements
Rank 1
answered on 10 Jun 2010, 09:54 AM
Hi Pavel,
Thank you. In your solution everthing works fine, but exactly the same code written in VB.NET does not update the Total-value if you change the Count-value. The Recalculate Method is fired correctly the data in the Data-Layer (Me.Total) is also ok. If you change the Price-value the value in Total-column is also ok. Please check. Thanks in advance.
Best regards
Stefan
Thank you. In your solution everthing works fine, but exactly the same code written in VB.NET does not update the Total-value if you change the Count-value. The Recalculate Method is fired correctly the data in the Data-Layer (Me.Total) is also ok. If you change the Price-value the value in Total-column is also ok. Please check. Thanks in advance.
Best regards
Stefan
Imports System |
Imports System.Collections.Generic |
Imports System.Linq |
Imports System.Net |
Imports System.Windows |
Imports System.Windows.Controls |
Imports System.Windows.Documents |
Imports System.Windows.Input |
Imports System.Windows.Media |
Imports System.Windows.Media.Animation |
Imports System.Windows.Shapes |
Imports System.ComponentModel |
Imports Telerik.Windows.Controls.GridView |
Imports Telerik.Windows.Controls |
Partial Public Class MainPage |
Inherits UserControl |
Public Sub New() |
InitializeComponent() |
Dim items As New List(Of Item)() |
items.Add(New Item() With { _ |
.Name = "Item1", _ |
.Count = 2, _ |
.Price = 10 _ |
}) |
items.Add(New Item() With { _ |
.Name = "Item2", _ |
.Count = 5, _ |
.Price = 20 _ |
}) |
Me.gridView.ItemsSource = items |
End Sub |
End Class |
Public Class Item |
Implements INotifyPropertyChanged |
Public Property Name() As String |
Get |
Return m_Name |
End Get |
Set(ByVal value As String) |
m_Name = value |
End Set |
End Property |
Private m_Name As String |
Private m_price As Decimal |
Public Property Price() As Decimal |
Get |
Return Me.m_price |
End Get |
Set(ByVal value As Decimal) |
Me.m_price = value |
Recalculate() |
End Set |
End Property |
Private m_count As Integer |
Public Property Count() As Integer |
Get |
Return Me.m_count |
End Get |
Set(ByVal value As Integer) |
Me.m_count = value |
Recalculate() |
End Set |
End Property |
Private m_total As Decimal |
Public Property Total() As Decimal |
Get |
Return Me.m_total |
End Get |
Set(ByVal value As Decimal) |
Me.m_total = value |
Me.OnPropertyChanged("Total") |
End Set |
End Property |
Private Sub Recalculate() |
Me.Total = Me.Price * Me.Count |
End Sub |
Private Sub OnPropertyChanged(ByVal [property] As String) |
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs([property])) |
End Sub |
#Region "INotifyPropertyChanged Members" |
Public Event PropertyChanged As PropertyChangedEventHandler |
#End Region |
Public Event PropertyChanged1(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged |
End Class |
0
Hello Stefan,
It seems the problem was in your implementation of the INotifyPropertyChanged interface.
The sample attached has some VB code working as expected.
Kind regards,
Pavel Pavlov
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.
It seems the problem was in your implementation of the INotifyPropertyChanged interface.
The sample attached has some VB code working as expected.
Kind regards,
Pavel Pavlov
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.
0
Stefan
Top achievements
Rank 1
answered on 10 Jun 2010, 03:57 PM
Hello Pavel,
You are right. I forgot: Implements INotifyPropertyChanged.PropertyChanged
behind the declaration Public Event PropertyChanged As PropertyChangedEventHandler.
Now it works as expected. Thank´s a lot for your great assistance!!!
Best regards
Stefan
You are right. I forgot: Implements INotifyPropertyChanged.PropertyChanged
behind the declaration Public Event PropertyChanged As PropertyChangedEventHandler.
Now it works as expected. Thank´s a lot for your great assistance!!!
Best regards
Stefan