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, what contains the necessary columns, as the user selects the years.


Attachment: Screenshots_3aea1109.zip


3 Replies 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team December 2, 2021 12:40 PM UTC

Hi Peter, 

Greetings from Syncfusion support. 

We have already validated the same scenario in the below forum but we are unable to reproduce the reported problem from our end. Please find the forum link for your reference.  


If you are still facing the reported problem then kindly share us the below details, 

  1. Share us the Syncfusion NuGet version details.
  2. Share us the video demo showing the reported problem.
  3. Share us the complete grid code with your model class and datasource.
  4. Kindly share us the issue reproducing sample or reproduce the reported problem in the above provided sample.

The above requested details will be helpful for us to validate your query and to provide you with a better solution as early as possible. 

Regards, 
Jeevakanth SP. 



Marked as answer

PE Peter December 7, 2021 10:17 AM UTC

Dear  Jeevakanth,

indeed, it is working well. It was my fault. Sorry to use your time for that.

Best regards:

Peter



JP Jeevakanth Palaniappan Syncfusion Team December 8, 2021 06:55 AM UTC

Hi Peter, 

Thanks for the update. Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon