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

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

2 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
EmpowerIT
Top achievements
Rank 2
EmpowerIT asked on 17 Jan 2008, 12:59 AM
Hi,
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:

  void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem itm in RadGrid1.Items) 
        { 
            if (itm.OwnerTableView.DataSourceID == "JobCodesSource"
            { 
                //Go through each of the items in there 
                int numChildRows = itm.ChildItem.NestedTableViews[0].Items.Count; 
                int numChanged = 0; 
                foreach (GridDataItem childItm in itm.ChildItem.NestedTableViews[0].ItemsHierarchy) 
                { 
                   string TechName = "Bill Gates"
 
                    if (childItm["TechnicianId"].Text != Techname) 
                    { 
                        childItm.CssClass = "MyCustomRowClass"
                        numChanged++; 
                    } 
                    TechniciansSource.SelectCommand = oldSelect; 
                } 
                if(numChanged == numChildRows) 
                    itm.CssClass = "MyCustomRowClass"
            } 
        } 
    } 

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

Thanks,

Fayez

2 Answers, 1 is accepted

Sort by
0
EmpowerIT
Top achievements
Rank 2
answered on 17 Jan 2008, 06:17 AM
Okay,
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?
0
Sebastian
Telerik team
answered on 17 Jan 2008, 09:13 AM
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,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
EmpowerIT
Top achievements
Rank 2
Answers by
EmpowerIT
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or