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

[Solved] how to style the left bar with arrows in hierarchy display

4 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sf
Top achievements
Rank 1
sf asked on 22 Apr 2009, 09:45 AM
my RadGrid has 3 leves: mastertableview --> detailtables --> detailtables.

It becomes hard to distinguish different levels as the records grow to a large number. Is it possible to change the colour of the left vertical bar which has the expand arrows?

thanks in advance

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Apr 2009, 10:41 AM
Hello,

 You can try out the following code to set different colors for expand column at different levels in a hierarchial grid:
c#:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
        { 
            if (dataItem.OwnerTableView.Name == "Master"
            { 
                dataItem["ExpandColumn"].CssClass = "mastertable"
                if (dataItem.Expanded) 
                { 
                    GridTableView nestedView = (GridTableView)dataItem.ChildItem.NestedTableViews[0]; 
                    foreach (GridDataItem item in nestedView.Items) 
                    { 
                        item["ExpandColumn"].CssClass="detailtable"
                    } 
                } 
        } 
    } 

css:
<style type="text/css"
  .mastertable 
  { 
    background-color:Red ; 
  } 
  .detailtable 
  { 
   background-color:Blue !important; 
  }     
</style> 

Thanks
Princy.
0
sf
Top achievements
Rank 1
answered on 28 Apr 2009, 04:22 AM
thanks for your help Princy, it worked initially. 

There is a large quantity of data in the grid. After I called a method to "expand all", the style disappearred. any idea how to deal with this situation? thanks
0
Shinu
Top achievements
Rank 2
answered on 28 Apr 2009, 07:23 AM
Hi,

I am not sure how you are expanding the the Grid rows. I tried expanding the entire Grid rows inside a button click on my end and the style applied for the expandcollapse column still remains.

Here is the code which I tried to expand the entire Grid rows(I have a 4 level hierarchical Grid).

CS:
 
protected
 void Button2_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
        { 
            dataItem.Expanded = true
             
                 
                if (dataItem.Expanded) 
                { 
                    GridTableView nestedView = (GridTableView)dataItem.ChildItem.NestedTableViews[0]; 
                    foreach (GridDataItem item in nestedView.Items) 
                    { 
                       
                        item.Expanded = true
 
                        if (item.Expanded) 
                        { 
                            GridTableView nestedView2 = (GridTableView)item.ChildItem.NestedTableViews[0]; 
                            foreach (GridDataItem childitem in nestedView2.Items) 
                            { 
                                childitem.Expanded = true
                               
                            } 
 
                        } 
                    } 
                } 
 
             
        } 
       
       
    } 


Here is the code which I tried to apply the style for the ExpandColumn.

protected
 void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
        { 
      
             
                dataItem["ExpandColumn"].CssClass = "mastertable"
                if (dataItem.Expanded) 
                { 
                    GridTableView nestedView = (GridTableView)dataItem.ChildItem.NestedTableViews[0]; 
                    foreach (GridDataItem item in nestedView.Items) 
                    { 
                        item["ExpandColumn"].CssClass = "detailtable"
                        //item.Expanded = true; 
 
                        if (item.Expanded) 
                        { 
                            GridTableView nestedView2 = (GridTableView)item.ChildItem.NestedTableViews[0]; 
                            foreach (GridDataItem childitem in nestedView2.Items) 
                            { 
                                //childitem.Expanded = true; 
                                childitem["ExpandColumn"].CssClass = "detailtable2"
                            } 
 
                        } 
                    } 
                } 
 
             
        } 
       
 
    } 


Shinu
0
sf
Top achievements
Rank 1
answered on 30 Apr 2009, 04:14 AM
thanks Shinu , I have managed to fix this issue on the original radgrid. However when I had another radgrid this issue came out again.... I will try more see if i can fix it myself, thanks again
Tags
Grid
Asked by
sf
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
sf
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or