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

[Solved] computed column

1 Answer 166 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.
iramz
Top achievements
Rank 1
iramz asked on 20 Jan 2010, 05:39 AM
Hi,

I have a radgridview that is bound to my custom entity. The first two columns is bound for example to Price and Quantity respectively in my Entity. I want a third column that will automatically compute/display Price x Quantity when the respective columns are edited. how do i do it in radgridview without modifying my entity.

many thanks!

1 Answer, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 25 Jan 2010, 12:01 PM
Hello iramz,

There are number of way to achieve the required functionality. For example you can:
  • Create a custom column that will display the computed value. Subscribe to the CellEditEnded event and update the the respective computed value if the edited cell is the one for price or quantity.
  • Make your class a partial class and add a new property in the partial class that wil do the computation. This way you will not modify your existing entity class. After that you can add a column bound to this new property.
  • Create a view model for you entities. You can create a view model object for each of your entities and bind the grid to the view models, instead of the original entities collection. I have done exactly this in the sample project that is attached to this thread. It is using MicroModels for Silverlight to simplify the creation of the view models. Hope you will find it useful.

Kind regards,
Stefan Dobrev
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.
Tags
GridView
Asked by
iramz
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Share this question
or