This is a migrated thread and some comments may be shown as answers.

Lists/Tables with DataSource having sub property containing list of objects

2 Answers 363 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 30 Dec 2013, 01:55 AM

I have been fighting this for over a week.  Digging through documentation, forums, bing, google, trial and error etc...  And for some reason I cannot figure out how to do something that should be simple.


The Scenario.

I have a data object, for example we will call it GroupDTO.  This object consists of some properties, for Example GroupName and GroupID.  It also has a property that is a list of another data object, we shall call it UserDTO, and the property on GroupDTO is List<UserDTO>.  UserDTO contains properties such as LogIn, FirstName and LastName.  Lets say the first groups name is Administrators and the second groups name is Commoners.  On my report I want it to show as...



Administrators

     Name

     Smith, John

     Doe, John

Commoners

     Name

     Doe, Jane



I have tried creating a list, setting my DataSource to GroupDTO.  Then setting it to a List<GroupDTO>.  This works.  Then I tried adding a row inside the group and inserting a second list into that row.  I set its DataSource to UserDTO then I created a binding of DataSource = ReportItem.DataObject.Users.  I added a row to this list outside of the group above and put Name in the first column.  Then in the second row (inside the group) I have two columns, one for LastName, and one for FirstName .  What I end up with is ....



Administrators

     Name

     Smith, John

     Doe, John

Commoners

     Name

     Smith, John

     Doe, John

Administrators

     Name

     Smith, John

     Doe, John

Commoners

     Name

     Smith, John

     Doe, John



So for some reason it is duplicating my group names, and then under the groups instead of getting the users for that group I get the users for the first group every time.  Can anyone send an example that works for my scenario, or figure out what I may be doing wrong?  I have verified that my data is correct in my List<GroupDTO>.  I am also using Telerik Reporting Q3 2010 version.

2 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 30 Dec 2013, 02:31 AM
Nevermind, I figured out my problem.  I had my reports data source = to the Groups list, then I had my list in the detail section on the report = to the same datasource, that is why it was listing them twice.  And I am about to do more testing but I am thinking it may have been what was affecting my strange results with the ReportItem.DataObject.
0
Stef
Telerik team
answered on 30 Dec 2013, 02:56 PM
Hello John,

Please take a look at the following articles which you may find helpful: How to Databind to Collection Properties and How to use ReportItem.DataObject property in expressions.

I hope this information helps you with your tests.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Stef
Telerik team
Share this question
or