Completed
Last Updated: 31 Oct 2016 13:31 by ADMIN
ADMIN
Hristo
Created on: 25 Oct 2016 14:04
Category: PivotGrid
Type: Bug Report
1
FIX. RadPivotGrid - the control is empty after performing a LINQ query and binding to an array of anonymous objects
How to reproduce:
   var data = this.dbContext.Orders.Where(o => o.OrderID > 10500).Select(o => new
            {
                Id = o.OrderID,
                OrderDate = o.OrderDate,
                ShipDate = o.ShippedDate,
                Freight = o.Freight
            }).ToArray();

this.localDataProvider = new LocalDataSourceProvider() {ItemsSource = data};

Workaround:
1. Instead of  ToArray call ToList
var data = this.dbContext.Orders.Where(o => o.OrderID > 10500).Select(o => new
{
    Id = o.OrderID,
    OrderDate = o.OrderDate,
    ShipDate = o.ShippedDate,
    Freight = o.Freight
}).ToList();

this.localDataProvider = new LocalDataSourceProvider() {ItemsSource = data};

2. Call the ToArray method but do not create anonymous objects.
var data = this.dbContext.Orders.Where(o => o.OrderID > 10500).Select(o => new PivotModel
{
    Id = o.OrderID,
    OrderDate = o.OrderDate,
    ShipDate = o.ShippedDate,
    Freight = o.Freight
}).ToArray();

this.localDataProvider = new LocalDataSourceProvider() {ItemsSource = data};

public class PivotModel
{
    public int Id { get; set; }

    public DateTime? OrderDate { get; set; }

    public DateTime? ShipDate { get; set; }

    public decimal? Freight { get; set; }
}

0 comments