Hello.
After you helped me in this thread, I was able to get nested tables working using a custom object.
I then revisited the topic, reread the links you provided and got it working with a dataset with datarelations established on the dataset. However, the solution I arrived at was so convoluted, I'm fairly certain that it isn't the intended way to accomplish that goal.
Could someone please look at the code below, tell me if it's the way we're intended to do this, and if not, provide an example of the correct method? I suspect I'm doing this incorrectly because of the all the casting going on down in the getChildItem f(x).
The workers class is for making the dataset, including the datarelations and some randomly generated data. To save typing I'm just grabbing the custom object from when I was testing that approach, and turning it into a dataset.
The createReportFromDS and getChildItem are in the actual report object. There are two table objects on the report: tblParent, and nested within it, tblChild.
After you helped me in this thread, I was able to get nested tables working using a custom object.
I then revisited the topic, reread the links you provided and got it working with a dataset with datarelations established on the dataset. However, the solution I arrived at was so convoluted, I'm fairly certain that it isn't the intended way to accomplish that goal.
Could someone please look at the code below, tell me if it's the way we're intended to do this, and if not, provide an example of the correct method? I suspect I'm doing this incorrectly because of the all the casting going on down in the getChildItem f(x).
The workers class is for making the dataset, including the datarelations and some randomly generated data. To save typing I'm just grabbing the custom object from when I was testing that approach, and turning it into a dataset.
The createReportFromDS and getChildItem are in the actual report object. There are two table objects on the report: tblParent, and nested within it, tblChild.
Public Function createReportFromDS() As Byte() Dim ods As New ObjectDataSource ods.DataSource = cboSample.workers.getWorkers ods.DataMember = "workers" 'casing has to match tblParent.DataSource = ods tblChild.Bindings.Add(New Telerik.Reporting.Binding("DataSource", "=getChildItem(ReportItem.DataObject)")) Return generateReportObj()End FunctionPublic Shared Function getChildItem(sender As Object) As DataTable Dim dataObject = DirectCast(sender, Telerik.Reporting.Processing.IDataObject) Dim dt As DataTable = CType(CType(dataObject.RawData, DataRowView).Row, DataRow).GetChildRows("WtoT").CopyToDataTable() Return dtEnd FunctionPublic Class workers Public Shared Function getWorkers() As DataSet Dim ds As DataSet = getDS() Dim myCbo As New dataItems Dim myWorkers As IEnumerable(Of parentItem) = myCbo.GetData 'to save typing just grab the custom object previously created and turn it into tables in a dataset Dim i As Integer 'process the items For Each w As parentItem In myWorkers ds.Tables("workers").Rows.Add(i, w.worker, w.age) For Each t As childItem In w.tasks ds.Tables("tasks").Rows.Add(i, t.taskName, t.timeRequired, t.difficulty.ToString) Next i += 1 Next Return ds End Function ''' <summary> ''' Returns a ds with columns and datarelations established ''' </summary> ''' <returns></returns> Private Shared Function getDS() As DataSet Dim dtP, dtC As DataTable Dim ds As New DataSet dtP = New DataTable("workers") dtP.Columns.Add("pk", GetType(Integer)) dtP.Columns.Add("worker") dtP.Columns.Add("age") dtP.PrimaryKey = New DataColumn() {dtP.Columns("pk")} dtC = New DataTable("tasks") dtC.Columns.Add("fk", GetType(Integer)) dtC.Columns.Add("taskName") dtC.Columns.Add("timeRequired") dtC.Columns.Add("difficulty") ds.Tables.AddRange(New DataTable() {dtP, dtC}) ds.Relations.Add("WtoT", ds.Tables("workers").Columns("pk"), ds.Tables("tasks").Columns("fk")) Return ds End FunctionEnd Class