Hello I am trying to generate Dynamic columns for Telerik Grid it is generating multiple times columns set I want to avoid this please check bellow screen short.
Here is the my code.
<TelerikGrid Data="@SearchConfigs" Resizable="true" Reorderable="true" Groupable="false">
<GridColumns>
@foreach (SearchConfig row in SearchConfigs)
{
@foreach (var property in (IDictionary<string, string>)row.SearchFields)
{
<GridColumn Title="@property.Key">
<Template>
@property.Value
</Template>
</GridColumn>
}
}
</GridColumns>
</TelerikGrid>
public List<SearchConfig> SearchConfigs { get; set; } = new List<SearchConfig>();
IDictionary<string, string> keyValuePairs = new Dictionary<string, string>
{
{ "Col1", "Value1" },
{ "Col2", "Value2" },
{ "Col3", "Value3" },
{ "Col4", "Value4" },
{ "Col5", "Value5" },
{ "Col6", "Value6" },
{ "Col7", "Value7" },
{ "Col8", "Value8" },
};
SearchConfigs.Add(new SearchConfig { SearchFields = keyValuePairs });
SearchConfigs.Add(new SearchConfig { SearchFields = keyValuePairs });
SearchConfigs.Add(new SearchConfig { SearchFields = keyValuePairs });
Could you please help me figure out what is going wrong here?
Thank you