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

[Solved] calculated column

8 Answers 156 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.
Jonam
Top achievements
Rank 1
Jonam asked on 08 Aug 2010, 09:24 PM
Hello,

i have a very simple question. I have a datagridview in silverlight with two databound columns. How do i create a third column that has the calculated value of column1 + column2.

kind regards,

Jonam

8 Answers, 1 is accepted

Sort by
0
Accepted
Vanya Pavlova
Telerik team
answered on 10 Aug 2010, 08:02 AM
Hi Jonam,

Please see the following here.

Greetings,
Vanya Pavlova
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
Jonam
Top achievements
Rank 1
answered on 15 Aug 2010, 05:38 PM
Hello,

thank you for the example. This providers a solution by declaring it in XAML. Can it also be done in code (c#)?

kind regards,

Jonam
0
Maya
Telerik team
answered on 16 Aug 2010, 07:27 AM
Hello Jonam,

There is no problem to define the calculated column in the code-behind. Thus following the example, that column would be like:

GridViewDataColumn calculatedColumn = new GridViewDataColumn();
calculatedColumn.TextAlignment = System.Windows.TextAlignment.Right;
calculatedColumn.DataMemberBinding = new Binding("Total");                     
this.gridView.Columns.Add(calculatedColumn);

You can find more information about defining columns in our online documentation.


Greetings,
Maya
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
Jonam
Top achievements
Rank 1
answered on 16 Aug 2010, 02:13 PM
Hello maya,

thank you for replying. In the online documentation you can find how to create columns with bindings to a value of an object but now how to bind to a calculated column. Do you know how this is possible?

kind regards,

Jonam
0
Maya
Telerik team
answered on 16 Aug 2010, 03:44 PM
Hello Jonam,

Please give us more specifics about your project. What is the purpose of binging to a column? Do you expect to get its values? 
 

Regards,
Maya
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
Jonam
Top achievements
Rank 1
answered on 17 Aug 2010, 07:33 AM
Hello Maya,

What i want in my project specified above and an answer is already given. I want column A to be a total of column B + C. The solution above works fine but i want to create the column dynamic in the code behind and not in the XAML. Do think this is possible?

kind regards,

Jonam
0
Accepted
Maya
Telerik team
answered on 17 Aug 2010, 09:41 AM
Hello Jonam,

I have prepared a sample project illustrating how to add the "Total" column dynamically on a Button-Click.
I hope that meets your requirements.
 

All the best,
Maya
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
Jonam
Top achievements
Rank 1
answered on 19 Aug 2010, 11:43 AM
Thanks Maya that was great!
Tags
GridView
Asked by
Jonam
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Jonam
Top achievements
Rank 1
Maya
Telerik team
Share this question
or