Reset column collection
Dear Syncfusion,
I implemented a grid, where the columns are created dynamically: please have a look on the attached pic, what shows the header part. I have to show data in columns as the user checks in the years. Per default, only the last two years are checked in (Fig. 1). The user clicks on the Filter button, all the data shows. Then the user checks in the previous year (2019), then clicks on the Filter, and I am expecting the Fig.2, however the columns of the grid are not changing. Can I reset the columns somehow, so when the new set of data arrive, the grid shows all the columns in the new dataset?
The problem is that I am generating the columns in the markup part like this:
<GridColumns>
@if (Orders != null && Orders.Any())
{
dynamic firstItem = Orders.First();
var dictionaryItem = (IDictionary<string, object>)firstItem;
var fields = dictionaryItem.Keys;
foreach (var item in dictionaryItem)
{
if (item.Key.ToLower() != "cgid")
{
<GridColumn Field="@item.Key"
Format="@(item.Key.ToLower().Contains("perc") ? "N1" : "N0")"
TextAlign="@(item.Key.ToLower().Contains("customer") ? TextAlign.Left : TextAlign.Right)">
</GridColumn>
}
}
}
</GridColumns>
Thanks!
PS: the grid is bound to a List
Attachment: Screenshots_3aea1109.zip
- Share us the Syncfusion NuGet version details.
- Share us the video demo showing the reported problem.
- Share us the complete grid code with your model class and datasource.
- Kindly share us the issue reproducing sample or reproduce the reported problem in the above provided sample.
Dear Jeevakanth,
indeed, it is working well. It was my fault. Sorry to use your time for that.
Best regards:
Peter