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

Alternate rows AND selected column

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 20 Jan 2009, 08:18 PM
In the grid I can specify alternate row CSS to add visual separation between rows
I can also add a CSS to the sorted column to add visual cue which column is currently sorted

So lets say I have alternating rows with white/gray/white/gray background
I also have CSS for sorted column that turns background of the sorted column to blue. All cells in sorted column now have blue background. Compare to nicely white/gray/white/gray schema of the unsorted column it looks ugly.

Question: How can I can specify alternate row CSS for the sorted column? So in the sample above I would get white/gray/white/gray for unsorted columns and dark blue/ligh blue/dark blue/light blue for sorted ones?

Thank you

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jan 2009, 05:33 AM
Hi Alex,

Give a try with the following approach and see whether it helps.

CS:
static string strColName; 
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Sort"
        { 
            strColName = e.CommandArgument.ToString(); 
        } 
    } 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            if ((e.Item.OwnerTableView.SortExpressions.Count > 0)) 
            { 
                GridDataItem item = (GridDataItem)e.Item; 
                 if (item.ItemType == GridItemType.Item) 
                     item[strColName].BackColor = System.Drawing.Color.Blue; 
                 else if (item.ItemType == GridItemType.AlternatingItem) 
                     item[strColName].BackColor = System.Drawing.Color.BlueViolet; 
 
                 GridSortExpression expresion = new GridSortExpression(); 
                 if (expresion.SortOrder == GridSortOrder.None) 
                     item[strColName].Style.Clear(); 
                 
            } 
 
        }   
  } 
 


Regards
Shinu
0
Alex
Top achievements
Rank 1
answered on 23 Jan 2009, 05:12 PM
Thank you!
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Alex
Top achievements
Rank 1
Share this question
or