HyperLink PivotGrid

6 posts, 0 answers
  1. Dr
    Dr avatar
    3 posts
    Member since:
    Mar 2013

    Posted 05 Nov 2013 Link to this post

    Could someone please provide an example of a PivotGrid that has HyperLinked Text? I would be most grateful
  2. Dr
    Dr avatar
    3 posts
    Member since:
    Mar 2013

    Posted 07 Nov 2013 Link to this post

    Is this possible? It would really help me out if someone could provide a sample of how to accomplish this. Thanks again.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 08 Nov 2013 Link to this post

    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.
  5. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 11 Nov 2013 Link to this post

    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();
            }
  6. Dr
    Dr avatar
    3 posts
    Member since:
    Mar 2013

    Posted 13 Dec 2013 Link to this post

    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
  7. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 18 Dec 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017