We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to place a weblink in the header of GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

78876 Jan 7,2009 07:18 PM UTC Jan 12,2009 12:55 PM UTC ASP.NET Web Forms (Classic) 3
loading
Tags: GridGroupingControl
Daniel Santos de Carvalho
Asked On January 7, 2009 07:18 PM UTC

I wanted to place a link to another page on the header of one column (and only on the header, not on every row of the column) of my GridGroupingControl.

When clicked, it should call a new page.

The columns are inserted dynamically, so i'm using "GridColumnDescriptor" to place the columns in my GridGroupingControl.

My code is as described below, but when i click on the header, it won't open the page, it also ignore the width:

GridColumnDescriptor col = new GridColumnDescriptor();
col.Name = "Find";
col.Width = 150;
col.Appearance.ColumnHeaderCell.CellType = "Link";
col.Appearance.ColumnHeaderCell.Tag = "http://www.syncfusion.com/FAQ/WinForms";

this.ggc.TableDescriptor.Columns.Add(col);
this.ggc.TableDescriptor.VisibleColumns.Add(col.Name);



Rekha P [Syncfusion]
Replied On January 9, 2009 06:43 AM UTC

Hi Daniel,

Thank you for your interest in Syncfusion Products.

To make a column header as hyperlink, you can create a TemplateClass to add a HyperLink instance. Please refer the code snippet below to achieve this.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridColumnDescriptor col = new GridColumnDescriptor();
col.Name = "Find";
col.Width = 150;

this.GridGroupingControl2.TableDescriptor.Columns.Add(col);
this.GridGroupingControl2.TableDescriptor.VisibleColumns.Add(col.Name);
}
this.GridGroupingControl2.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(GridGroupingControl2_QueryCellStyleInfo);
}

void GridGroupingControl2_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell)
{
if (e.TableCellIdentity.Column.Name == "Find")
{
HyperLink hypLink = new HyperLink();
hypLink.ID = "Find1";
hypLink.Text = e.Style.CellValue.ToString();
hypLink.NavigateUrl = "http://www.syncfusion.com/FAQ/WinForms";
hypLink.Target = "_blank";

TemplateClass mytemp = new TemplateClass(hypLink);
e.TableCellIdentity.Column.HeaderTemplate = mytemp;
e.Handled = true;
}
}
}

public class TemplateClass : ITemplate
{
private Control m_ctrlChildControl = null;
public TemplateClass(Control ctrlChildControl)
{
m_ctrlChildControl = ctrlChildControl;
}

public void InstantiateIn(Control container)
{
container.Controls.Add(m_ctrlChildControl);
}
}


Also please refer the sample below which illustrates the column hiding and then delete the selected record.

http://websamples.syncfusion.com/samples/Grid.Web/6.4.0.15/F78876_HeaderCol_HyperLink/main.htm

Thank you for being patient and please let me know if this sample helps you.

Thanks,
Rekha


Daniel Santos de Carvalho
Replied On January 12, 2009 12:27 PM UTC

Worked very well, thanks Rekha


Rekha P [Syncfusion]
Replied On January 12, 2009 12:55 PM UTC

Hi Daniel,

Thanks for the update and please let me know if you have any other concerns.

Thanks,
Rekha


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;