Changing styles of parent rows based on detail tables when not expanded

3 posts, 0 answers
  1. EmpowerIT
    EmpowerIT avatar
    117 posts
    Member since:
    Jun 2007

    Posted 16 Jan 2008 Link to this post

    I am trying to apply some custom styles to rows based on values that are present in their child rows. I can only get this to work correctly if i have the HierarchyDefaultExpanded property set to true. By doing this, the radgrid looks very cluttered. Basically, i need to find out if there is a way to tell if a row has been expanded or not.

    My code is below:

    1   void RadGrid1_PreRender(object sender, EventArgs e) 
    2     { 
    3         foreach (GridDataItem itm in RadGrid1.Items) 
    4         { 
    5             if (itm.OwnerTableView.DataSourceID == "JobCodesSource"
    6             { 
    7                 //Go through each of the items in there 
    8                 int numChildRows = itm.ChildItem.NestedTableViews[0].Items.Count; 
    9                 int numChanged = 0; 
    10                 foreach (GridDataItem childItm in itm.ChildItem.NestedTableViews[0].ItemsHierarchy) 
    11                 { 
    12                    string TechName = "Bill Gates"
    14                     if (childItm["TechnicianId"].Text != Techname) 
    15                     { 
    16                         childItm.CssClass = "MyCustomRowClass"
    17                         numChanged++; 
    18                     } 
    19                     TechniciansSource.SelectCommand = oldSelect; 
    20                 } 
    21                 if(numChanged == numChildRows) 
    22                     itm.CssClass = "MyCustomRowClass"
    23             } 
    24         } 
    25     } 

    The problem is that when the row is not expanded, the count is 0.
    0 is a valid count of rows as well, as some rows will not have any items beneath them, and I want their style to also change. Is their someway of finding out all the childitems of a row without expanding the row?

    I already tried setting the HeiarchyLoadMode for the child table to be client but that didnt help either.

    I basically need two things:

    1. A way of knowing whether or not the row is expanded

    2. The child items of the row when it is not expanded



  2. EmpowerIT
    EmpowerIT avatar
    117 posts
    Member since:
    Jun 2007

    Posted 17 Jan 2008 Link to this post

    I've answered my first question, I can tell whether or not a row has been expanded, but that still doesnt solve my second problem

    I need to know about the children of that item, even though they are not expanded.

    Any ideas?
  3. DevCraft R3 2016 release webinar banner
  4. Sebastian
    Sebastian avatar
    9934 posts

    Posted 17 Jan 2008 Link to this post

    Hello EmpowerIT,

    Unless the corresponding parent item is expanded you will not be able to gather information about the child records because they are not accessible for collapsed rows. This is done due to performance reasons. Hence you will need to verify that the respective parent row is expanded (or expand all rows at that level setting HierarchyDefaultExpanded = true) to operate with the child records.

    Best regards,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top