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

HyperLink PivotGrid

5 Answers 189 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Dr
Top achievements
Rank 1
Dr asked on 05 Nov 2013, 09:13 PM
Could someone please provide an example of a PivotGrid that has HyperLinked Text? I would be most grateful

5 Answers, 1 is accepted

Sort by
0
Dr
Top achievements
Rank 1
answered on 07 Nov 2013, 03:27 PM
Is this possible? It would really help me out if someone could provide a sample of how to accomplish this. Thanks again.
0
Eyup
Telerik team
answered on 08 Nov 2013, 12:44 PM
Hello,

You can refer to the following sample and use Templates provided by RadPivotGrid in order to achieve the desired functionality:
http://demos.telerik.com/aspnet-ajax/pivotgrid/examples/templates/defaultcs.aspx

Hope this helps.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Barbaros Saglamtimur
Top achievements
Rank 1
answered on 11 Nov 2013, 11:20 AM
Here is how I use;

<telerik:PivotGridRowField DataField="ItemGroup" UniqueName="ItemGroup" ZoneIndex="1">
                            <CellTemplate>
                                <uc1:celltemplate ID="celltemplate1" runat="server" />
                            </CellTemplate>
</telerik:PivotGridRowField>

celltemplate.ascx
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="#" Text="<%#GetCellText() %>"></asp:HyperLink>


celltemplate.ascx.cs
private PivotGridRowHeaderCell _container;
        public PivotGridRowHeaderCell Container
        {
            get { return _container ?? (_container = Parent as PivotGridRowHeaderCell); }
        }
        protected string GetCellText()
        {
            //Actually there is a javascript string returning here
            return Container.DataItem.ToString();
        }
0
Dr
Top achievements
Rank 1
answered on 13 Dec 2013, 06:55 PM
Very helpful, Thank You!

Another question though. If I wanted to use data from another table as the HyperLink value instead of "#", how would I accomplish this?

The table I'm using in the DataField of the PivotGridRow is "Title", which are the names of Video Titles. But I want the HyperLink to be the Alias of the Title, which is a different Table.

Title: Iron Qon Raid Video
Alias: iron-qon-raid-video
0
Eyup
Telerik team
answered on 18 Dec 2013, 02:32 PM
Hello,

Please note that RadPivotGrid uses compressed data from the source ,therefore, accessing and manipulating DataItem info is not straightforward as it is with RadGrid:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

In this sense, I'm afraid it is not possible to pass multiple Field values into the Cell template. You will need to make a call to the database or manually set the NavigateURL of the HyperLinks:
protected void RadPivotGrid1_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e)
{
    if (e.Cell.Field != null && e.Cell.Field.UniqueName == "ShipName")
    {
        PivotGridRowHeaderCell cell = e.Cell as PivotGridRowHeaderCell;
 
        HyperLink link = cell.FindControl("HyperLink1") as HyperLink;
        string url = "http://wikipedia.org/wiki/" + cell.DataItem.ToString().Replace(" ", "-");
        link.NavigateUrl = url.ToLowerInvariant();
    }
}

I hope the clarification was helpful.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
PivotGrid
Asked by
Dr
Top achievements
Rank 1
Answers by
Dr
Top achievements
Rank 1
Eyup
Telerik team
Barbaros Saglamtimur
Top achievements
Rank 1
Share this question
or