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

Master/Detail Row Colors

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Timothy Kruszewski
Top achievements
Rank 1
Timothy Kruszewski asked on 17 Sep 2010, 05:23 PM
I have a Master/Detail grid control and need some help with item style and alternating stlye row colors.  In my scenario the master/detail grid is always expanded and I would like each master/detail row to be the same colors.  So row 1 master/detail records would both be blue and row 2 master/detail would both be white and this would continue for the rest of the grid.  I've provided a screen shot with the current color scheme for reference.

Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Sep 2010, 06:09 AM
Hello Timothy,

The following code snippet shows how to set alternative colors for mater/detail grid.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
          {
               GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];
               if (item.ItemIndex % 2 == 0)
               {
                   item.BackColor = System.Drawing.Color.Blue;
                   foreach (GridItem childItem in tableView.Items)
                       childItem.BackColor = System.Drawing.Color.Blue;
               }
               else
               {
                   item.BackColor = System.Drawing.Color.White;
                   foreach (GridItem childItem in tableView.Items)
                       childItem.BackColor = System.Drawing.Color.White;
               }
           }
      }

-Shinu.
Tags
Grid
Asked by
Timothy Kruszewski
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or