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