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

Compare two cells values in different rows then apply formatting.

1 Answer 600 Views
GridView
This is a migrated thread and some comments may be shown as answers.
willie johnson
Top achievements
Rank 1
willie johnson asked on 27 Apr 2010, 08:26 PM

Hello,

I need help I am trying to compare to cells value in different rows grouped within in a grid. The groups will alway contain only two rows becauase user select two selections from a combox then click on a compare button and it display the result from the first and second selected items in the combox so they can see the difference between the two. I have alreay tried summaryrows it doesn't allow for calculating different between the two, alway highlighting the cells with colors (red) will allow for easy spot of differences.

 

Any help is surely appreciated.

grid
-----------------------------------
Outter GridView
--------------------
column 1 |  column 2 | column 3 | column 4 | column 5

Inner GridViewTemplate (groupBy column 1): will always have two rows of data
------------------
Group 1
 column 1 | columns 2 | columns 3 | column 4
Name1 | 98.45 (red) | 35.33 (yellow) | comments data
Name1 | 98.47 (red) | 35.33 (yellow)  | comments data

Group 2
 column 1 | columns 2 | columns 3 | column 4
Name2 | 100.23(yellow) | 35.33 (yellow) | comments data
Name2 | 100.23 (yellow) | 35.33 (yellow)  | comments data

 

Group 1
 column 1 | columns 2 | columns 3 | column 4
Name3 | 45.21(red) | 35.33 (red) | comments data
Name3 | 46.23(red) | 35.89(red)  | comments data

If columns 2 or 3 values are different make cell red for that group else make color yellow

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 29 Apr 2010, 11:10 AM
Hi willie johnson,

You can use CellFormatting event to customize the appearance of grid cells. The following KB article demonstrates this technique. In order to compare the column values you should iterate all group rows. This can be done by accessing the ParentRow.Group property of GridViewDataRowInfo.


A bit off topic, please ask the person who has purchased our controls in your company to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/account/faqs.aspx.

Best wishes,
Jack
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.
Tags
GridView
Asked by
willie johnson
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or