get a cell value on a hierearchical gridview

3 posts, 0 answers
  1. Yaroslav
    Yaroslav avatar
    24 posts
    Member since:
    Nov 2011

    Posted 27 Feb 2012 Link to this post

    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.

  2. Yaroslav
    Yaroslav avatar
    24 posts
    Member since:
    Nov 2011

    Posted 28 Feb 2012 Link to this post

    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
  3. Stefan
    Stefan avatar
    2908 posts

    Posted 01 Mar 2012 Link to this post

    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;
                  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.
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top