Bind OData Service to a PivotGrid

0 Answers 57 Views
DataServiceDataSource GridView PivotGrid
Sebastian
Top achievements
Rank 1
Sebastian asked on 23 Feb 2022, 02:47 PM

Hi,

I tried to use the RadGridView with an OData Endpoint. 

I took a look into the documentations but didn't find any good sample.

I tried it with the QueryableDataProvider.

But my data was not loaded. It always runs into an exception:

Constructing or initializing instances of the type DynamicClass1 with the expression (Param_0 != null) is not supported.

This Exception is thrown by the OData Client.

 

Below my simplified code:

 

View:


<Window x:Class="ODataClientTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:oDataClientTest="clr-namespace:ODataClientTest"
        xmlns:pivot="http://schemas.telerik.com/2008/xaml/presentation/pivot"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800"
        d:DataContext="{d:DesignInstance oDataClientTest:MainWindowViewModel}">
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        
        <pivot:RadPivotGrid Grid.Row="0" Grid.Column="0" DataProvider="{Binding ReportElements}" />
        
        <pivot:RadPivotFieldList Grid.Row="0" Grid.Column="1" DataProvider="{Binding ReportElements}" />

    </Grid>
</Window>


ViewModel

 


using System.Diagnostics;
using Telerik.Pivot.Queryable;

namespace ODataClientTest;

public class MainWindowViewModel : BaseNotifyPropertyChanged
{
    public MainWindowViewModel()
    {
        MyOdataContext dataContext = new();

        ReportElements = new()
                         {
                             Source = dataContext.ReportElements,
                             DeferUpdates = true
                         };

        ReportElements.StatusChanged += (sender, args) =>
                                        {
                                            if (args.Error != default)
                                                Debugger.Break(); // Here I can see the exception
                                        };
    }

    public QueryableDataProvider ReportElements
    {
        get => GetValue<QueryableDataProvider>();
        set => SetValue(value);
    }
}

 

 

My Question now: Is there any way to connect my OData Source to a PivotGrid?

Unfortunalety I could not use the LocalDataProvider, as the OData API returns a lot of data which must be filtered beforehand.

 

I also tried to use the normal GridView with works perfectly with the QueryableDataServiceCollectionView. But: It does not fit our needs, like Grouping, Creating dynamic aggregates (sum, average, etc.).

We are currently using .Net 4.7.2.

 

Many thanks!


 

Sebastian
Top achievements
Rank 1
commented on 02 Mar 2022, 02:33 PM

Valid point. But for us is currently OData much simpler than GraphQL. Neverthenless I see no possibility to connect a GraphQL Endpoint to an Pivot Grid in order to provide some configurable reporting UI.

So for us is currently OData the technology of choice.

No answers yet. Maybe you can help?

Tags
DataServiceDataSource GridView PivotGrid
Asked by
Sebastian
Top achievements
Rank 1
Share this question
or