Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF RadGridView Footer Not Updating Values on GridView Change
    primarykey
    data
    text
    <p>I have a Telerik RadGridView Bound to ObservableCollection of defined type.. On Updating the value of a particular property in that type, the corresponding RadGridView cells are getting updated but not the total in the footer..i have created the dependency property for the same, but getting error: Set property 'System.Windows.Setter.Property' threw an exception.</p> <p><strong>Below is the XAML:</strong> </p> <pre><code>&lt;ComboBox Grid.Column="4" Width="100" Margin="4" ItemsSource="{Binding Path=ResultUnits, Mode=OneTime}" SelectedValue="{Binding Path=ResultUnit}"/&gt; &lt;telerik:RadGridView ItemsSource="{Binding Path=Results, Mode=TwoWay}" FooterRowStyle="{StaticResource GridViewFooterStyle}" Width="{Binding RelativeSource={RelativeSource AncestorType= ScrollViewer}, Path=ActualWidth}" ColumnWidth="*" RowIndicatorVisibility="Collapsed" EditTriggers="None" IsFilteringAllowed="False" AutoGenerateColumns="False" AllowDrop="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" ShowGroupPanel="False" ShowColumnFooters="True"&gt; &lt;telerik:RadGridView.Resources&gt; &lt;Style TargetType="{x:Type telerik:RadGridView}"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.UpdateFooter}" Value="True"&gt; &lt;Setter Property="my:UpdateGridViewFooter.HandleGridViewUpdateFooterProperty" Value="True" /&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/telerik:RadGridView.Resources&gt; &lt;telerik:RadGridView.Columns&gt; &lt;telerik:GridViewDataColumn Header="Quantity" DataMemberBinding="{Binding Path=Quantity}"&gt; &lt;telerik:GridViewColumn.AggregateFunctions&gt; &lt;telerikData:SumFunction SourceField="Weight"/&gt; &lt;/telerik:GridViewColumn.AggregateFunctions&gt; &lt;/telerik:GridViewDataColumn&gt; &lt;/telerik:RadGridView.Columns&gt; &lt;/telerik:RadGridView&gt; </code></pre> <p><strong>Below is the View Model Code:</strong></p> <pre><code>public class ViewModel { private const decimal PoundsToKilograms = 0.45359237M; private const decimal GramstoPound = 0.00220462262M; private ObservableCollection&lt;Result&gt; results; public EnvironmentalSummaryViewModel() { this.results= new ObservableCollection&lt;Result&gt;(); } public ObservableCollection&lt;Result&gt; Results{ get { return this.results; } set { this.results = value; } } public string ResultUnit { get { return this.resultUnit; } set { if (this.resultUnit != value) { this.resultUnit = value; this.UpdateGridViewValuesOnResultUnitChanged(); } } } public bool UpdateFooter { get; set; } private void UpdateGridViewValuesOnResultUnitChanged() { bool isEnglish = this.resultUnit == this.resultUnits[0]; this.results.ToList().ForEach(result =&gt; { decimal weight = isEnglish ? result.Weight * GramstoPound * 1000 : environmental.Weight * PoundsToKilograms; result.Weight = Math.Round(weight, 2); }); } this.UpdateFooter = true; } </code></pre> <p><strong>Object Class:</strong></p> <pre><code>public class Result{ private decimal weight; public decimal Weight { get { return this.weight;} set { this.weight = value; ((IHaveOnPropertyChangedMethod) this).OnPropertyChanged("Weight"); } } } </code></pre> <p><strong>Dependency Property:</strong></p> <pre><code>public static class UpdateGridViewFooter { /// &lt;summary&gt; /// Handle GridView Footer Update Attached Dependency Property /// &lt;/summary&gt; public static readonly DependencyProperty HandleGridViewUpdateFooterProperty = DependencyProperty.RegisterAttached( "HandleGridViewUpdateFooter", typeof(bool), typeof(UpdateGridViewFooter), new FrameworkPropertyMetadata(false, new PropertyChangedCallback(UpdateFooterOnValueChanged))); /// &lt;summary&gt; /// Gets the GridView Footer Update property. /// &lt;/summary&gt; /// &lt;param name="d"&gt;The DependencyObject&lt;/param&gt; /// &lt;returns&gt;The bool value&lt;/returns&gt; public static bool GetHandleGridViewUpdateFooterProperty(DependencyObject d) { return (bool) d.GetValue(HandleGridViewUpdateFooterProperty); } /// &lt;summary&gt; /// Sets the GridView Footer Update property. /// &lt;/summary&gt; /// &lt;param name="d"&gt;The DependencyObject&lt;/param&gt; /// &lt;param name="value"&gt;The bool value&lt;/param&gt; public static void SetHandleGridViewUpdateFooterProperty(DependencyObject d, bool value) { d.SetValue(HandleGridViewUpdateFooterProperty, value); } public static void UpdateFooterOnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var radGridView = d as RadGridView; if (radGridView != null) { radGridView.CalculateAggregates(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload