Hi,
I have a tough time dealing with Infragistics xamPivotGird. I have classes say Customer and Address.
public class Customer
{
string Name {get; set;}
Address CustAddress {get; set;}
}
public Address
string Street{get; set;}
string State {get; set;}
string City {get; set;}
string ZipCode {get; set;}
In some cases, when my Address is null. while creating Hierarchy, using the below code, I don't see the Hierarchy being built or show up when expanded
var hierarchy = new HierarchyDescriptor<Customer>(p => p.CustAddress );
hierarchy.AddLevel(p => "All Addresses", "All Addresses");
hierarchy.AddLevel(p => p.CustAddress.ZipCode?? "", "ZipCode");
Please guide me here.....Its kind of urgent.
Hi Rajib,
The expression is evaluated when you expand the "All Addresses" hierarchy. If the address is null then that code is going to fail with a NullReferenceException. You should see the NullReferenceException in your Visual Studio output window. Please change your expression to handle the null value. Something like this perhaps:
hierarchy.AddLevel(p => (p.CustAddress == null) ? "" : p.CustAddress.ZipCode, "ZipCode");
I have a class Customer. How can I expose the property(Amount) of Order as a measure, if I create a Cube out of List of Customers(basically FlatDataSource).
Order CustOrder {get; set;}
public Order
string OrderNum {get; set;}
double Amount {get; set;}
The only other option I can think of is to use custom aggregators. This lets you create a measure from which you can control what value is displayed in the pivot grid cells. You will still need to create an aggregator for each property you wish to use as a measure though, so I don't think it's easier than the suggestion I made earlier. Please see the following about aggregators:
http://help.infragistics.com/doc/WPF/2015.1/CLR4.0/?page=xamPivotGrid_US_CustomAggregators.html
Rob,
Thanks for the con
I have at least 20 or more such properties. It will be practically impossible to add so many properties. Do you have any better idea ?
Also, I have 10-15 such kind of classes which might need similar treatment.
Unfortunately the FlatDataSource can't use Amount as a measure because it is not part of the Customer class. Since the FlatDataSource is a List of Customers, measures can only come from the Customer class. So if it is required to show Amount as a measure, a property should be added to the Customer class which gets the Amount from the CustOrder property.
public double Amount { get { return (CustOrder == null) ? 0.0 : CustOrder.Amount; } }