Welcome to the Blazor feedback portal. We’re happy you’re here! If you have feedback on how to improve the Blazor, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

2
Votes

Template with grouping throws null reference exception.


@using Syncfusion.Blazor.DropDowns

<h3>Subscriptions</h3>

<SfDropDownList TValue="string" TItem="CDisplayItem" DataSource="@m_Subscriptions">

<DropDownListFieldSettings GroupBy="Category" Value="Code" Text="Text"></DropDownListFieldSettings>

<DropDownListTemplates TItem="CDisplayItem">

<ItemTemplate>

<div class="row">

<div class="col"><span>@((context as CDisplayItem).Text)</span></div>

<div class="col text-info">

@if ((context as CDisplayItem).Subscription.Remark.Length > 0)

{

<span>@((context as CDisplayItem).Subscription.Remark)</span>

}

</div>

</div>

</ItemTemplate>

</DropDownListTemplates>

</SfDropDownList>

@code {

private List<CDisplayItem> m_Subscriptions;

protected override void OnInitialized()

{

m_Subscriptions = new List<CDisplayItem>();

m_Subscriptions.Add(new CDisplayItem() { Code = "C", Text = "Children", Category = "Child", Subscription = new CSubscription() });

m_Subscriptions.Add(new CDisplayItem() { Code = "CC", Text = "Children (cassette)", Category = "Child", Subscription = new CSubscription() });

}

public class CDisplayItem

{

public CSubscription Subscription;

public string Code { get; set; }

public string Text { get; set; }

public string Category { get; set; }

}

public class CSubscription

{

public string Remark { get; set; } = "";

}

}

Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Template_groupby_issue-2122592648