Hyperlink Grid Group Header with DataSource property value

Is it possible to target a DataSource property value from a custom CaptionTemplate in the GridGroupSettings in order to hyperlink the Group Header title on a unique value to the group?

<GridGroupSettings Columns=@InitialGroup ShowDropArea="false">
    <CaptionTemplate>
      @{
          var workspace = (context as CaptionTemplateContext);
             <div style="display: inline-block; margin-top:3px;">
                 <a rel='nofollow' href=<DataSourceProperty> class="workspacelink">@workspace.Key </a>
             </div>
          }
</CaptionTemplate>
</GridGroupSettings>

3 Replies

NP Naveen Palanivel Syncfusion Team September 5, 2022 08:56 PM UTC

Hi Riley,


Greetings from Syncfusion support.


We checked your query by given code and prepared sample in the CaptionTemplate  of GridGroupSettings with  hyperlink for  the Group Header title. We also attached the sample in this ticket. Please refer the attached sample for your reference.


If we misunderstand the query please give more details, Kindly share the below details to validate further at our end.


  1. Share us entire Grid code snippet along with model class.
  2. Share us the video demonstration of the issue with detailed replication procedure
  3. If possible share us an simple issue reproduceable sample or try to reproduce the reported issue on the above mentioned sample. 

The above-requested details will be helpful for us to validate the reported query at our end and provide the solution as early as possible.


Regards,

Naveen Palanivel


Attachment: BlazorApp1_(3)_92ffcfb8.zip


RG Riley Grant September 6, 2022 04:58 PM UTC

Thank you for looking into this Naveen but I don't think this is quite what I'm looking for.

Modifying your example a bit, I'm trying to somehow get a different property into the link value of the hyperlink tag while grouping on the OrderID. It would look more like this, where the MyURL property has been added to the Order class -


@{
var Template = (new string[] { "OrderID" });
}
<SfGrid DataSource="@Orders" AllowGrouping="true" Height="400">
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order1 ID" TextAlign="TextAlign.Right" Width="120">GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150">GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130">GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120">GridColumn>
GridColumns>
<GridGroupSettings Columns=@Template>
<CaptionTemplate>
@{
var order = (context as CaptionTemplateContext);
<div>
<a rel='nofollow' href=@MyURL > @order.Field </a>
@order.Key
div>
}
CaptionTemplate>
GridGroupSettings>
SfGrid>

@code{
public List<Order> Orders { get; set; }

protected override void OnInitialized()
{
Orders = Enumerable.Range(1, 75).Select(x => new Order()
{
OrderID = 1000 + x,
CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
Freight = 2.1 * x,
OrderDate = DateTime.Now.AddDays(-x),
MyURL = "www.syncfusion.com"
}).ToList();
}

public class Order
{
public int OrderID { get; set; }
public string CustomerID { get; set; }
public DateTime? OrderDate { get; set; }
public double? Freight { get; set; }
public string MyURL { get; set; }
}
}




NP Naveen Palanivel Syncfusion Team September 8, 2022 01:09 AM UTC

Hi Riley,


We checked your and prepared as per the requirement for  the MyURL property has been added to the class property. We attached the sample in this ticket , Please refer the attached sample for your reference.


you have further queries, please get back to us


Regards,

Naveen Palanivel


Attachment: BlazorApp1_(2)_41746e1c.zip

Loader.
Up arrow icon