For what it's worth...
I've gotten it to work properly for Master-Detail reports that only have one level of detail. I'm getting an ArgumentException with DevExpress's components for a Master-Detail report with 2 detail levels (e.g. Suppliers.Products works, Suppliers.Products.Orders does not).
As Frans suggested, the method for creating the reports is:
1. Create a DataSet
2. Add TypedLists to the DataSet and create the relationship between the Parent and child tables.
3. Bind the report's dataSource to the DataSet
4. Bind the report's DataMember to the name of the relationship
5. Bind the detail report's controls (labels, table cells, etc.) with the DataMember set to RelationShipName.ColumnName. The Master controls should be bound using MasterTableName.ColumnName.
Sample code:
// Master (parent) band
wines = WineCollection.GetMultiAsDataTable(selectFilter, 0, sortClause);
wines.TableName = TABLE_NAME_WINE;
reportDS.Tables.Add(wines);
wineAddition.Fill(0, additionSortClause, false, selectFilter);
wineAddition.TableName = TABLE_NAME_WINE_ADDITION;
reportDS.Tables.Add(wineAddition);
reportDS.Relations.Add(RELATIONSHIP_NAME_WINE_ADDITION, wines.Columns[(int)WineFieldIndex.WineId], wineAddition.Columns[(int)WineAdditionSummaryTypedListFieldIndex.WineId]);
this.DataSource = reportDS; //DataSet which stores all datatables.
this.DataMember = TABLE_NAME_WINE;
additionReport.DataSource = reportDS;
additionReport.DataMember = RELATIONSHIP_NAME_WINE_ADDITION;
yAdditionComments.DataBindings.Add("Text", reportDS, RELATIONSHIP_NAME_WINE_ADDITION + "." + wineAddition.Columns[(int)WineAdditionSummaryTypedListFieldIndex.Description].ColumnName);
Also, the XtraReports sample projects set the DataMember field for Detail reports to be "ParentTableName.ChildTableName" not the name of the relationship. Using the TableName.ChildTableName doesn't work with TypedLists.
I don't know what's going on when I try to create a report with a 3rd level of detail. For some reason, XtraReports seems to have issues navigating the heirachy.
If I have 3 tables, with the relationship like: Wine->movements->wineMovementContainerFrom, I assume that I just define the relationship to be between the 2nd and 3rd table, since there is already a relationship from the 1st to 2nd table.
// 2nd -> 3rd table relationship
reportDS.Relations.Add(movements.Columns["PKFieldName"], wineMovementContainerFrom.Columns["FKFieldName"]);
Is that correct?
Thanks.
(At the risk of veering even farther off topic, here's the XtraReports Stack trace for the exception, in case anyone has seen this before.)
System.ArgumentException: WineWineMovement.WineMovementFrom
at DevExpress.Data.Browsing.DataContext.GetDataBrowserInternal(Object dataSource, String dataMember)
at DevExpress.Data.Browsing.DataContext.get_Item(Object dataSource, String dataMember)
at DevExpress.XtraReports.Native.XRDataContext.get_Item(Object dataSource, String dataMember)
at DevExpress.XtraReports.UI.XtraReportBase.get_DataBrowser()
at DevExpress.XtraReports.UI.XtraReportBase.WriteToDocument(DocumentBuilder docBuilder)
at DevExpress.XtraReports.Native.Printing.DetailWriter.WriteDetail()
at DevExpress.XtraReports.Native.Printing.DetailWriterWithDS.WriteInternal()
at DevExpress.XtraReports.Native.Printing.DetailWriter.Write()
at DevExpress.XtraReports.Native.Printing.DocumentBuilder.Build()
at DevExpress.XtraReports.UI.XtraReportBase.BuildDocument(DocumentBuilder builder)
at DevExpress.XtraReports.UI.DetailReportBand.BuildDocument(DocumentBuilder builder)
at DevExpress.XtraReports.UI.XtraReportBase.WriteToDocument(DocumentBuilder docBuilder)
at DevExpress.XtraReports.Native.Printing.DetailWriter.WriteDetail()
at DevExpress.XtraReports.Native.Printing.DetailWriterWithDS.WriteInternal()
at DevExpress.XtraReports.Native.Printing.DetailWriter.Write()
at DevExpress.XtraReports.Native.Printing.DocumentBuilder.Build()
at DevExpress.XtraReports.Native.Printing.RootReportBuilder.Build()
at DevExpress.XtraReports.UI.XtraReportBase.BuildDocument(DocumentBuilder builder)
at DevExpress.XtraReports.UI.XtraReport.BuildDocument(DocumentBuilder builder)
at DevExpress.XtraReports.UI.XtraReport.CreateDocument(PrintingSystem ps, Single progressRange)
at DevExpress.XtraReports.UI.XtraReport.CreateDocument(Single progressRange)
at DevExpress.XtraReports.UI.XtraReport.CreateIfEmpty(Single progressRange)
at DevExpress.XtraReports.UI.XtraReport.ShowPreview()