This is a migrated thread and some comments may be shown as answers.

editable row and dynamic aggregation function

3 Answers 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jerry
Top achievements
Rank 1
Jerry asked on 22 May 2012, 03:42 AM
Hi there,


Currently, I'm working on a grid, where use is allowed to change the value of the cell. I have an aggregation function for this column. Everything is fine as long as user doesn't change the value. The aggregate value doesn't seem to change upon user change cell value.

How should I do this, so the aggregated value will get updated upon user change one of the cells' value? By the way, I use a custom aggregate function this case.

xmal
<controls:RadGridView x:Name="ProjectRiskAnswersGridView" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Top" VerticalContentAlignment="Stretch"
                 Grid.Row ="1"
                 ItemsSource="{Binding RiskAnswers, Mode=TwoWay}"
                 DataLoadMode="Asynchronous"
                 CanUserDeleteRows="False"
                 CanUserFreezeColumns="False"
                 CanUserReorderColumns="False"
                 CanUserResizeColumns="False"
                 RowIndicatorVisibility="Collapsed"
                 IsFilteringAllowed="False"
                 GridLinesVisibility="None"
                 ShowGroupPanel="False"
                 CanUserSortColumns="True"
                 AutoGenerateColumns="False"
                 ValidatesOnDataErrors="None"
                 ShowColumnFooters="true"
                 SelectionMode="Single"
                  
                      >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn UniqueName="RiskAreaColumn" IsReadOnly="True" DataMemberBinding="{Binding RiskQuestion.RiskArea.RiskAreaText, Mode=TwoWay, ValidatesOnDataErrors=False}" Header="Area"  />
        <telerik:GridViewDataColumn UniqueName="RiskQuestionColumn" IsReadOnly="True" DataMemberBinding="{Binding RiskQuestion.QuestionText, Mode=TwoWay, ValidatesOnDataErrors=False}" Header="Question" Width="500" />
        <local:RatingColumn UniqueName="RiskRatingColumn" IsReadOnly="True" DataMemberBinding="{Binding Rating, Mode=TwoWay, ValidatesOnDataErrors=False}" CellTemplate="{StaticResource RatingTemplate}" Header="Rating"  Width="200" />
        <telerik:GridViewDataColumn UniqueName="RiskPointsColumn" IsReadOnly="False" DataMemberBinding="{Binding Point, Mode=TwoWay, ValidatesOnDataErrors=False}" Header="Points" >
            <telerik:GridViewDataColumn.AggregateFunctions>
                <local:TotalPointsFunction Caption="Total: "/>
            </telerik:GridViewDataColumn.AggregateFunctions>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
</controls:RadGridView>

xmal.cs
public class TotalPointsFunction : EnumerableAggregateFunction
{
    protected override string AggregateMethodName
    {
        get { return "TotalPoints"; }
    }
 
    protected override Type ExtensionMethodsType
    {
        get { return typeof(Functions); }
    }
}
 
public static partial class Functions
{
    public static int? TotalPoints<TSource>(IEnumerable<object> source)
    {
        var totalPoints = source.OfType<RiskAnswer>().Aggregate<RiskAnswer, int?>(0, (current, riskAnswer) => current + riskAnswer.Point);
        return totalPoints;
    }
}


thank you


regards
Jerry

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 22 May 2012, 06:01 PM
Hi Jerry,

 When a PropertyChanged is raised then the aggregate result should be updated. I have tested the described functionality on this online demo and the aggregate results were updated once I committed the editing.

Please let me know what have you done differently.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jerry
Top achievements
Rank 1
answered on 22 May 2012, 11:42 PM
Hi Didie,


Thank you for your reply.


Well, I don't think the demo actually fit into my problem. Since the rows is not editable in the demo.

I have attached a few screenshots. 1.png shows the loading screen, which is correct. But 2.png, shows that after I edited a few rows, the aggregated value didn't get updated.

Um, is it possible that you give me a sample project for this?

thank you for your time.


regards
Jerry
0
Dimitrina
Telerik team
answered on 23 May 2012, 08:01 AM
Hello Jerry,

Indeed your point is right. I have attached the test project based on the demo I suggested. After you edit a value in the StadiumCapacity column, you will notice that the aggregate is updated once the edit has been committed.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Jerry
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Jerry
Top achievements
Rank 1
Share this question
or