Dear support,
we are using an SfGrid displaying data from a dynamic DataSource in Sf Blazor ver. 18.2.0.56. Dynamic DataSource means we bind a List<DynamicEntity>, where DynamicEntity is Derived from System.Dynamic.DynamicObject and implementing IDynamicMetaObjectProvider.
After binding, we dynamically build the columns of the grid by iterating over the DynamicObject's Properties.
This all works flawlessly, including pagination, export, etc.; The grid is inserted into a component like this:
<SfGrid @ref="@DataGrid" DataSource="@AccessableEntities" TValue="SelectableDynamicEntity" AllowSelection="true" AllowPaging="true">
<GridSelectionSettings Type="SelectionType.Single" Mode="SelectionMode.Row" EnableToggle="false"></GridSelectionSettings>
<GridEvents RowSelected="HandleSfSelectionChange" OnRecordDoubleClick="HandleSfRowDoubleClick" TValue="SelectableDynamicEntity"></GridEvents>
<GridColumns>
<GridColumn Field="ID" IsPrimaryKey="true" Visible="false" />
@foreach (var objCol in ColDefs)
{
<GridColumn Field="@objCol.Field" HeaderText="@objCol.Caption" AllowSorting="@objCol.AllowSort" />
}
</GridColumns>
</SfGrid>
But, problems arise when trying to enable filtering the Grid. Adding 'AllowFiltering="true"' to the SfGrid, and
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu" ShowFilterBarStatus="true" />
as well as per column:
<GridColumn Field="@objCol.Field" HeaderText="@objCol.Caption" AllowFiltering="@objCol.AllowFilter" AllowSorting="@objCol.AllowSort" />
Causes an exception like the following as soon as the user opens the Filter Menu of a column:
Syncfusion.Blazor.Data.EnumerableOperation.GetColumnType(System.Collections.IEnumerable, string, System.Type)
Syncfusion.Blazor.Data.EnumerableOperation.PredicateBuilder(System.Collections.IEnumerable, System.Collections.Generic.List<Syncfusion.Blazor.Data.WhereFilter>, string, System.Linq.Expressions.ParameterExpression, System.Type)
Syncfusion.Blazor.Data.EnumerableOperation.PerformFiltering(System.Collections.IEnumerable, System.Collections.Generic.List<Syncfusion.Blazor.Data.WhereFilter>, string)
Syncfusion.Blazor.Data.BlazorAdaptor.DataOperationInvoke<T>(System.Collections.IEnumerable, Syncfusion.Blazor.DataManagerRequest)
Syncfusion.Blazor.Data.BlazorAdaptor.PerformDataOperation.AnonymousMethod__0()
System.Threading.Tasks.Task<TResult>.InnerInvoke()
System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, object)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
I already tried to add a custom DataAdaptor instead of the builtin BlazorAdaptor into the grid like the following, to aid our debugging:
<SfGrid @ref="@DataGrid" TValue="SelectableDynamicEntity" AllowSelection="true" AllowFiltering="true" AllowPaging="true">
<SfDataManager Json=@AccessableEntities Adaptor="Adaptors.CustomAdaptor" DataAdaptor="MyDataAdaptor"></SfDataManager>
...
</SfGrid>
But unfortunately, even doing so, and even although the grid itself is correctly using the new Adaptor, the FilteringMenu still uses the default BlazorAdaptor in its PerformFiltering operation (I assume it is doing so while populating the search-as-you-type suggestions inside the FilterMenu).
My question now:
What must I ensure to make the Filtering work with a DynamicObject DataSource? Must I implement a custom DataAdaptor? If so, how can I ensure this is always used? Or, do I NOT need to implement a custom Adaptor, but must I ensure some prerequisites in the DynamicObject class, aside implementing IDynamicMetaObjectProvider?
Any help is greatly appreciated.
Regards,
Tim