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

Calculated Column refresh

1 Answer 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dirk Liebich
Top achievements
Rank 1
Dirk Liebich asked on 24 Aug 2011, 12:58 PM
All,

I have a calculated column in my grid. It works pretty fine but once I change one of the correspondig fields (Qt1...Qty18) the Total column doesn't update automatically. Is it supposed to calculate only once upon loading the grid or can I somehow accomplish to calculate on the fly once a depended column changes?

Thanks,
Lars

...
<telerik:GridViewExpressionColumn
                        Header="Total"
                        UniqueName="Total"
                        DataFormatString="{}{0:#,##0}"
                        />
...

In the constructor of the code behind I have the following lines:

    Expression<Func<ForecastInputItemViewModel, double>> expression = prod => prod.Qty1 + prod.Qty2 + prod.Qty3 + prod.Qty4 + prod.Qty5 + prod.Qty6 + prod.Qty7 + prod.Qty8 + prod.Qty9 + prod.Qty10 + prod.Qty11 + prod.Qty12 + prod.Qty13 + prod.Qty14 + prod.Qty15 + prod.Qty16 + prod.Qty17 + prod.Qty18;
            GridViewExpressionColumn column = ForecastGrid.Columns["Total"] as GridViewExpressionColumn;
            column.Expression = expression;

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 26 Aug 2011, 01:43 PM
Hi Dirk Liebich,

 Generally the GridViewExpressionColumn cells listen to the PropertyChanged event of the row's data item in order to update themselves. Your business object should raise PropertyChanged  whenever a property of the object has changed.

Please take a look at this online demo

I hope that this will help you. 

All the best,
Didie
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

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