Hi Jeevakanth,
Option (1) is the right idea, though (1) it would be preferable to do the filtering within the grid if possible (rather than using an external dropdown) and (2) rather than a list of strings, it's a list of models returned by the OData backend with an id from which the string can be looked up.
An Organisation looks like:
public class Organisation {
public Guid Id {get; set;}
public ICollection<CountryPresence> CountryPresences {get; set;}
}
public class CountryPresence {
public Guid OrganisationId {get; set;} public Guid CountryId {get; set;}
}
There's also a Country class:
public class Country {
public Guid Id {get; set;} public string ShortName {get; set;}
}
The code for the grid is:
.@code {
[Inject]
private IODataEndpointProvider EndpointProvider { get; set; }
[Inject]
private ICountryProvider CountryProvider { get; set; }
private SfGrid<Organisation> Grid { get; set; }
private Dictionary<Guid, Country> countryLookup = new Dictionary<Guid, Country>();
protected override async Task OnInitializedAsync()
{
ICollection<Country> countries = await CountryProvider.GetAll();
countryLookup = countries.ToDictionary(c => c.Id, c => c);
}
}
<SfGrid @ref="@Grid" AllowFiltering="true" AllowPaging="true" TValue="Organisation">
<GridEvents TValue="Organisation"></GridEvents>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<SfDataManager Url="@EndpointProvider.OrganisationsEndpoint" CrossDomain="false" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
<GridPageSettings PageSize="10"></GridPageSettings>
<GridColumns>
<GridColumn Field="@nameof(Organisation.Id)" HeaderText="Organisation ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field="@($"{nameof(Organisation.CountryPresences)}")" HeaderText="Countries" Width="150">
<Template>
@{
foreach (CountryPresence countryPresence in (context as Organisation).CountryPresences)
{
Country country = countryData[countryPresence.CountryId];
<CountryIndicator text="@(country.ShortName)" />
}
}
</Template>
</GridColumn>
</GridColumns>
</SfGrid>
Thanks,
Rob