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

Added Custom Header Row - How Do I Apply Your "Sorted" CSS Class To It?

1 Answer 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sir
Top achievements
Rank 1
Sir asked on 23 Dec 2010, 09:01 PM
Telerik.Web.UI v2010.3.1109.35

We have a radgrid (Theme/Skin="Windows7") and we've added a custom header row like this:

// ***** Add Grid Header Summary Row *****
GridItem[] header = this.MyWorkRadGrid.MasterTableView.GetItems(GridItemType.Header);
//get the current THead element   
GridTHead head = ((GridTHead)header[0].Parent.Controls[1].Parent);
 
//create a new GridHeaderItem which will be the new row   
GridHeaderItem newHeaderItem = new GridHeaderItem(this.MyWorkRadGrid.MasterTableView, 0, 0);
newHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = " " });
newHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = " " });
newHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = count, ColumnSpan = 5, Width = new Unit(100, UnitType.Percentage), HorizontalAlign = HorizontalAlign.Left, VerticalAlign = VerticalAlign.Middle });
 
for (int i = 0; i < head.Controls.Count; i++)
{
    // loop through the header controls collection and find the 'row' that has the same type of GridHeaderItem
    // Then insert the new row just above it - remember the 0 based index will push the original header row down
    if (head.Controls[i].GetType() == newHeaderItem.GetType())
    {
        head.Controls.AddAt(i, newHeaderItem);
    }
}

Our custom inserted header row takes on the windows 7 grid theme, which is cool.
But my boss wants to see if we can style this custom row with your existing "sorted by" column css style - which is like a split gradient.

If you look at the attached image (the customer data is fake data) -
The grid data is sorted by the "Contact Name" column, and so that column header has one of your css classes on it (circled in red)
The custom header I added is the one with the text "(9) Recent Contacts" (red arrow) and that is the row we want your sorted css class on.

Thanks,
Ray

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 29 Dec 2010, 03:52 PM
Hi,

The sort icon in the grid header is an image button which is either inivible or takes one of the following classes when the respective column is sorted: rgSortAsc, rgSortDesc.
You can try setting the classes and the visibility of your custom button in the SortCommand/ItemCommand event of the grid for the column which is being sorted.

Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Sir
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or