How to access header cell in multi column header?

0 Answers 165 Views
Grid
yuki
Top achievements
Rank 2
Iron
Iron
Iron
yuki asked on 19 Jul 2023, 01:55 AM | edited on 12 Sep 2023, 03:04 AM

Please see the attached picture. I have a Grid with multi column headers. How do I access header cells where red arrows and green arrow are pointing at respectively?

Accessing header cells is happening in RadGrid1_OnPreRender().

BTW, how to visually indicate filtering for grid with multi column header ? I tried this code in: https://docs.telerik.com/devtools/aspnet-ajax/knowledge-base/grid-visually-indicate-filtered-columns-in-excel-like-filtering

It works fine with common grid, but for grid with multi colum headers, it has bugs and cannot show properly.

Thank you!

Neha
Top achievements
Rank 2
Iron
Iron
commented on 21 Jul 2023, 11:55 AM

Try this


protected void RadGrid1_OnPreRender(object sender, EventArgs e)
{
    if (RadGrid1.MasterTableView.HasMultiHeaders)
    {
        foreach (GridColumnGroup group in RadGrid1.MasterTableView.ColumnGroups)
        {
            foreach (GridHeaderItem headerItem in group.HeaderCells)
            {
                // Access the header cell and perform any required operations.
                string headerText = headerItem.Text;
                // ...
            }
        }
    }
}

You may need to handle the filtering logic and UI customization manually.

 

yuki
Top achievements
Rank 2
Iron
Iron
Iron
commented on 12 Sep 2023, 03:03 AM | edited

Hi, Neha, thanks for providing the answer. However, I tried your code and cannot find group.HeaderCells, are you sure GridColumnGroup has this attribute?

No answers yet. Maybe you can help?

Tags
Grid
Asked by
yuki
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or