Filtering/Grouping not working with ExpandoObject Attribute

Hello

I have a problem for which I developed a solution based on the documentation BUT I have another implementation I tried which works in some cases but not for all functions.

What I'm trying to do: Load a grid, then dynamically add new columns based on data in a certain column of that grid (It's data stored in JSON format).

For example I have a class "Order" with properties "OrderID" and "Attributes".
Order ID could be 1, 2, 3, ... Attributes could be "{"comment":"my comment", "myValue": 2} ...

Now when I create the grid I create NEW columns based on "Attributes" columns, and the result is a grid with columns: Order ID, comment, myValue

Attached I have a project with two solutions.
The first solution is in Counter.razor. Just create a whole ExpandoObject. This works fine!

In Index.razor however, I have a Class with fixed properties BUT try to access my new column values via ExpandoObject getter implementation:

        public ExpandoObject Attribute
        {
            get
            {
                var eo = new ExpandoObject();
                if (Attributes != null)
                {
                    foreach (var attribute in Attributes)
                    {
                        eo.TryAdd(attribute.Key, attribute.Value);
                    }
                }
                return eo;
            }
        }

This works for displaying values BUT does not work for grouping and filtering.
Is there a supported approach to make this work or is the first solution the best approach?

Cheers,
Lazar



Attachment: GridExampleSupport_e1ad2068.7z

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team December 30, 2020 11:25 AM UTC

Hi Lazar, 

Greetings from Syncfusion support. 

Query : Is there a supported approach to make this work or is the first solution the best approach? 
Currently we don’t have support for mixed model in DataGrid. So we suggest you to use the first solution type which you have used in Counter.razor to achieve this requirement. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon