any change to make it work, or ability to create pivot?
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Dynamic objects cannot be used with AutoGenerateColumns=true
System.ArgumentException: Dynamic objects cannot be used with AutoGenerateColumns=true
at Telerik.Blazor.Components.TelerikGrid`1.<
OnParametersSetAsync
>d__247[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
16 Answers, 1 is accepted
i also checked Datatable approach as a datasource of the grid, seems will not work too due to converting to dictionary on OnRead event
i need to build pivot grid based on the data we have, so thу number of columns will be dynamic, any suggestions?
Hi Aleksandr,
A Pivot grid is a very far cry from a regular grid. You can Follow a pivot grid component here: https://feedback.telerik.com/blazor/1480716-pivot-grid.
As for generating columns with expandos - you can do that in a simple loop, see this example: https://github.com/telerik/blazor-ui/blob/master/grid/binding-to-expando-object/BindingToExpandoObject/Pages/AutoGeneratedColumns.razor
The same general approach for "autogenerating" columns from a datatable applies too - you know the field names in the datatable, you can loop over them.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Aleksandr,
The expando object example is linked from the DataBinding section of the grid: https://docs.telerik.com/blazor-ui/components/grid/overview#data-binding. Do you have something else in mind?
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Glad to see you moving forward, Aleksandr!
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Mirin,
is filter operations allowed for ExpandoObject source?
<
GridColumn
Field
=
"@item.Key"
FieldType
=
"@typeof(int)"
Width
=
"100px"
Locked
=
"true"
></
GridColumn
>
when i try to filter using standard menu filter
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Specified cast is not valid.
System.InvalidCastException: Specified cast is not valid.
at System.Linq.Enumerable.WhereListIterator`1[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].GetCount(Boolean onlyIfCheap)
at System.Linq.Enumerable.Count[ExpandoObject](IEnumerable`1 source)
at System.Linq.EnumerableExecutor`1[[System.Int32, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Execute()
at System.Linq.EnumerableQuery`1[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].System.Linq.IQueryProvider.Execute[Int32](Expression expression)
at Telerik.DataSource.Extensions.QueryableExtensions.Count(IQueryable source)
at Telerik.DataSource.Extensions.QueryableExtensions.CreateDataSourceResult[Object,Object](IQueryable queryable, DataSourceRequest request, Func`2 selector)
at Telerik.DataSource.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable queryable, DataSourceRequest request)
at Telerik.DataSource.Extensions.QueryableExtensions.ToDataSourceResult(IEnumerable enumerable, DataSourceRequest request)
at Telerik.Blazor.Data.TelerikDataSourceBase.ProcessData(IEnumerable data)
at Telerik.Blazor.Components.Common.DataBoundComponent`1[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ProcessDataInternal()
at Telerik.Blazor.Components.Common.DataBoundComponent`1.<
ProcessDataAsync
>d__22[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
DataBoundProcessData
>d__345[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
ProcessDataAsync
>d__340[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
ApplyFiltersAsync
>d__280[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
OnFilterChange
>d__278[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Telerik.Blazor.Components.Common.Filters.FilterMenu.TelerikFilterMenu.Filter()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Telerik.Blazor.Components.Common.Filters.FilterMenu.FilterMenuForm.OnFilterClick()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
same think for custom filter, it just does not find anything
<
FilterMenuTemplate
>
@{
<
div
class
=
"filter-values-container"
>
@foreach (var fieldValue in @ViewModel.Data.Where(_ => !string.IsNullOrEmpty((string)((IDictionary<
string
, object>)_)[item.Key])).DistinctBy(_ => (string)((IDictionary<
string
, object>)_)[item.Key]))
{
var fldV = (string)((IDictionary<
string
, object>)fieldValue)[item.Key];
<
div
>
<
TelerikCheckBox
Value
=
"@(GetFilterValues(context.FilterDescriptor).Contains(fldV))"
ValueChanged="@((bool value) => ColumnValueChanged(value, fldV, item.Key, context.FilterDescriptor))"
Id="@($"{item.Key}_{fldV}")">
</
TelerikCheckBox
>
<
label
for
=
"@($"
{item.Key}_{fldV}")">
@fldV
</
label
>
</
div
>
}
</
div
>
}
</
FilterMenuTemplate
>
same code works fine is we have Types object instead of Expando
Hi Aleksandr,
The built-in filtering works, you can compare against the sample project: https://github.com/telerik/blazor-ui/tree/master/grid/binding-to-expando-object to see what's the difference causing issues.
For custom filter tempaltes - it is up to the application code to build correct filters and mismatch between the types will cause errors.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
yes, for Id GetType shows that is System.Int64, changed to
<
GridColumn
Field
=
"@item.Key"
FieldType
=
"@typeof(System.Int64)"
Width
=
"100px"
Locked
=
"true"
></
GridColumn
>
started working, for custom invesigating
Marin,
so the problem is in comparison, for standard objects work fine even if we change it to FilterOperator.Contains
filterDescriptor.FilterDescriptors.Add(new FilterDescriptor(columnName, FilterOperator.IsEqualTo, itemValue));
for expandoObject it will raise the error that the property should be string
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Provided expression should have string type (Parameter 'stringExpression')
System.ArgumentException: Provided expression should have string type (Parameter 'stringExpression')
at Telerik.DataSource.Expressions.ExpressionFactory.LiftStringExpressionToEmpty(Expression stringExpression)
at Telerik.DataSource.Expressions.FilterOperatorExtensions.GenerateToLowerCall(Expression stringExpression, Boolean liftMemberAccess)
at Telerik.DataSource.Expressions.FilterOperatorExtensions.GenerateCaseInsensitiveStringMethodCall(MethodInfo methodInfo, Expression left, Expression right, Boolean liftMemberAccess)
at Telerik.DataSource.Expressions.FilterOperatorExtensions.GenerateContains(Expression left, Expression right, Boolean liftMemberAccess)
at Telerik.DataSource.Expressions.FilterOperatorExtensions.CreateExpression(FilterOperator filterOperator, Expression left, Expression right, Boolean liftMemberAccess)
at Telerik.DataSource.Expressions.FilterDescriptorExpressionBuilder.CreateBodyExpression()
at Telerik.DataSource.FilterDescriptor.CreateFilterExpression(ParameterExpression parameterExpression)
at Telerik.DataSource.FilterDescriptorBase.CreateFilterExpression(Expression instance)
at Telerik.DataSource.Expressions.FilterDescriptorCollectionExpressionBuilder.CreateBodyExpression()
at Telerik.DataSource.CompositeFilterDescriptor.CreateFilterExpression(ParameterExpression parameterExpression)
at Telerik.DataSource.FilterDescriptorBase.CreateFilterExpression(Expression instance)
at Telerik.DataSource.Expressions.FilterDescriptorCollectionExpressionBuilder.CreateBodyExpression()
at Telerik.DataSource.Expressions.FilterExpressionBuilder.CreateFilterExpression()
at Telerik.DataSource.Extensions.QueryableExtensions.Where(IQueryable source, IEnumerable`1 filterDescriptors)
at Telerik.DataSource.Extensions.QueryableExtensions.CreateDataSourceResult[Object,Object](IQueryable queryable, DataSourceRequest request, Func`2 selector)
at Telerik.DataSource.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable queryable, DataSourceRequest request)
at Telerik.DataSource.Extensions.QueryableExtensions.ToDataSourceResult(IEnumerable enumerable, DataSourceRequest request)
at Telerik.Blazor.Data.TelerikDataSourceBase.ProcessData(IEnumerable data)
at Telerik.Blazor.Components.Common.DataBoundComponent`1[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ProcessDataInternal()
at Telerik.Blazor.Components.Common.DataBoundComponent`1.<
ProcessDataAsync
>d__22[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
DataBoundProcessData
>d__345[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
ProcessDataAsync
>d__340[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
ApplyFiltersAsync
>d__280[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Telerik.Blazor.Components.TelerikGrid`1.<
OnFilterChange
>d__278[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Telerik.Blazor.Components.Common.Filters.FilterMenu.TelerikFilterMenu.Filter()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Telerik.Blazor.Components.Common.Filters.FilterMenu.FilterMenuForm.OnFilterClick()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
any thoughts to make it work?
here is the solution
filterDescriptor.FilterDescriptors.Add(new FilterDescriptor(columnName, FilterOperator.IsEqualTo, itemValue){MemberType = typeof(string)});
Hello,
I made another example for you: https://github.com/telerik/blazor-ui/blob/master/grid/binding-to-expando-object/BindingToExpandoObject/Pages/CustomFiltering.razor
Setting the MemberType of the FilterDescriptor is always mandatory when you are adding a new one, and it must match the type of the actual object. In the example I made above, its an integer.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Here's the feature request I made on your behalf for that that you can Follow: https://feedback.telerik.com/blazor/1493975-add-filterdescriptor-constructor-that-can-also-take-the-membertype
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Aleksandr,
To know when a feature is implemented, click the Follow button on its portal page, for example - the one for the pivot grid: https://feedback.telerik.com/blazor/1480716-pivot-grid
I must note that I can't promise a pivot grid will handle expandos, at least in v1, and I very much doubt it will generate columns or dimensions based on them.
With the grid, you should still loop over the deired info and generate the columns that way, we have a sample of that: https://github.com/telerik/blazor-ui/blob/master/grid/binding-to-expando-object/BindingToExpandoObject/Pages/AutoGeneratedColumns.razor