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

get a cell value on a hierearchical gridview

2 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yaroslav
Top achievements
Rank 1
Yaroslav asked on 27 Feb 2012, 12:50 PM
I have a hierarchical grid that contains 2 child gridviews. When a particular value on the 3rd gridview (3rd level of hierarchy) is shown then another cell should change its color. For the first grid is not a problem at all. But when trying to do so for the inner gridviews I fail to get the correct cell value.

I'm trying to follow the sample provided on the link Applying formatting only to cells in a child template but is only works for one level hierarchy verifying that the parent template is not nothing. On my case this is not helpfull has there is a parent and "grandparent" template.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Yaroslav
Top achievements
Rank 1
answered on 28 Feb 2012, 01:20 PM
Solved my self...I was pointing to the correct template, but a previous existing code prevented to access that particular procedure where I'm doing all the visual changes
0
Stefan
Telerik team
answered on 01 Mar 2012, 12:12 PM
Hi Yaroslav,

I am glad to hear that you have solved your case. However, by the time you have replied, I have already prepared an answer for you, which is indeed another approach, and for your convenience I will post it.

The example given is indeed for the second level only. However, you can always check the HierarchyLevel of the CellElement's RowInfo to determine which level you want to customize. Here is an example, which makes all data cells in level 3 yellow:
void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
      {
          if (e.CellElement is GridDataCellElement && e.CellElement.RowInfo.HierarchyLevel == 3)
          {
              e.CellElement.BackColor = Color.Yellow;
              e.CellElement.NumberOfColors = 1;
              e.CellElement.DrawFill = true;
          }
          else
          {
              e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
              e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, Telerik.WinControls.ValueResetFlags.Local);
              e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
 
          }
      }

I hope that you find this information useful. Let us know if you have any other questions.
 
Greetings,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Yaroslav
Top achievements
Rank 1
Answers by
Yaroslav
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or