When I drag them into my grid. Only the names of the classes just show up (SampleDataGeneratorNS.Seller) instead of all the columns/rows. Tried everything I can think of but I am pretty new at this Infragistics stuff. What am I doing wrong? (Code is attached)
Thanks!-Jesse
Hi,
Because XamPivotGrid analyzes flat data your data should be in table view. I mean that your data source should be like non normalized table and should contain simple types. In your Sale class you have Product property from type Product. The control cannot analyze this property as data and handles the property with its ToString() method. So to expose the mean full text you should create new property which returns the Product.Name property as shown below:
public class Sale { public Product Product { get; set; } public Seller Seller { get; set; } public DateTime Date { get; set; } public string City { get { return Seller.City; } set { Seller.City = value; } } public int NumberOfUnits { get; set; } public double AmountOfSale { get { return Product.Price * NumberOfUnits; } set { Product.Price = value / NumberOfUnits; } } public string ProductName { get { return this.Product.Name; } } public string SallerName { get { return this.Seller.Name; } } }
Regards
Hi
Another way is to create hierarchy for these complex properties. If you uncomment code for hierarchy it will work as you expect.
HierarchyDescriptor<Sale> sellerHierarchy = new HierarchyDescriptor<Sale>(p => p.Seller); sellerHierarchy.AddLevel(p => "All sellers", "All sellers"); sellerHierarchy.AddLevel(p => p.Seller.Name, "Seller name"); flatDataSource.AddHierarchyDescriptor(sellerHierarchy); HierarchyDescriptor<Sale> productHierarchy = new HierarchyDescriptor<Sale>(p => p.Product); productHierarchy.AddLevel(p => "All products", "All products"); productHierarchy.AddLevel(p => p.Product.Name, "Product name"); flatDataSource.AddHierarchyDescriptor(productHierarchy);
Todor
The reason to not see the hierarchy is that you have two definitions of Sale class. One in MainPage file and one in SampleDataGenerator.cs file.
When you describe hierarchy with code below
HierarchyDescriptor<Sale> sellerHierarchy = new HierarchyDescriptor<Sale>(p => p.Seller);
You actually use Sale class from MainPage, but your data are from SampleDataGenerator. So remove the definition of Sale class from main page.
Okay, I got it figured out. It turned out I just needed to add ToString functions for Products and Sellers:
Product
{
; }
ToString()
Name;
}
Seller
Hi Todor,
Thanks for the reply!
I'm sorry to be so dense -- I'm a competent programmer, but the infragistics API seems really inscrutable. I've tried what you suggested (attached) and I don't see any change in behavior (attached). Any other suggestions?
-Jesse