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

How to find Grid ExpandCollapseColumn Header in Code ?

5 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jai
Top achievements
Rank 1
Jai asked on 21 Jun 2011, 01:21 PM
Hi,

I have one situation where i want to find the header of Grid and apply the custom css. In grid I have following column and want to get the header of this column in code
            <ExpandCollapseColumn Visible="True">
            </ExpandCollapseColumn>
                <telerik:GridTemplateColumn UniqueName="AssociateColumn">
                    <ItemTemplate>
                        <asp:HyperLink ID="Lnktest" runat="server" Text="test"></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>

I have follwoing code to get the header and i am able to get that for other columns but not for this above column.

if (e.Item is GridHeaderItem)
            {
                GridHeaderItem item = (GridHeaderItem)e.Item;
                foreach (GridColumn col in GridAttorney.MasterTableView.Columns)
                {
                    if (col is GridEditCommandColumn || col is GridButtonColumn)
                    {
                        item[col.UniqueName].CssClass = "gridsBlankheadercolumn";
                    }
                }
            }

Can anyone tell me How to get this Column header in this above code ? Also please see the attached screenshot for better understanding.

Thanks,
--Jai

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2011, 03:43 PM
Hello Jai,

Try the following code snippet to achieve your scenario.
C#:
foreach (GridColumn col in RadGrid1.MasterTableView.Columns)
     {
        if ( col is GridTemplateColumn)//checking for template column
          {
            // set css from here
          }
       if (col is GridExpandColumn)//checking for ExpandColumn
          {
             //set css from here
          }
    }

Thanks,
Shinu.
0
Jai
Top achievements
Rank 1
answered on 25 Jun 2011, 04:00 PM
Hi Shinu,

No luck. I used GridExpandColumn but unable to do that i am looking for. ANy other approch ?

Thanks,
--Jai
0
Iana Tsolova
Telerik team
answered on 29 Jun 2011, 11:05 AM
Hello Jai,

Try traversing the RenderColumns or AutoGeneratedColumns collection instead of Columns.

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.

0
Jai
Top achievements
Rank 1
answered on 30 Jun 2011, 04:57 AM
Hi Lana,

Can you please give me some more detail here or What do you mean by traversing the RenderColumns or AutoGeneratedColumns collection ?

Thanks,
--Jai
0
Iana Tsolova
Telerik team
answered on 30 Jun 2011, 08:52 AM
Hi Jai,

Just replcate Columns with AutogeneratedColumn or RenderColumns in your code:
foreach (GridColumn col in RadGrid1.MasterTableView.AutogeneratedColumns)
{
    if ( col is GridTemplateColumn)//checking for template column
    {
        // set css from here
    }
    if (col is GridExpandColumn)//checking for ExpandColumn
    {
        //set css from here
    }
}


Best wishes,
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
Jai
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jai
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or