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

Using list of objects as datasource

1 Answer 600 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jarod
Top achievements
Rank 1
Jarod asked on 13 Nov 2010, 12:05 AM
I'm looking at an alternative to Crystal Reports and I'm down to two choices:  Telerik or DevExpress.

To be honest, I really like Telerik on the whole a lot more, especially with the WinForms controls but if I can't get this simple task by today I can't look past it.  I have an application that reads data from mixed xml sources, processes the data in a list of classes and prints out a report.  Nothing fancy, no drill-downs, just as if they were datarows.

So basically the class would look like:

public class MyDataClass
{
 public int MyInt { get; set; }
 public string MyString { get; set; }
 public DateTime MyDate { get; set; }
 
 public MyDataClass()
 {
 }
}

As it's computing, it puts it into a List<MyDataClass> that gets stored until it's ready.  The data source wizard detects it once I put in [DataObject] attribute on the class.  From here, both Crystal Reports and DevExpress can easily be hooked up to the list of objects easily.  Once it knows the type definition, I can set the datasource property to the list and it works.

But I cannot for the life of me find a simple or straightforward way to do this in Telerik.  Since there are 12 types of classes I'm processing, do I need to create 12 generic collections that each implement IEnumerable?  And then where do I hook in my actual instance of data?  Am I misunderstanding the terminology that Telerik Reporting is using?  Datasource is usually literally the source of the data.  But in the documentation, it appears to be used as the data definition.

This is simple stuff, but I haven't found any simple answer.  The demo page just shows a video, but doesn't show the code behind (unless I missed it).  Sure, the demo is great for showing what it can do, but it's incomplete in telling us how.  I'm running out of time before I need to give a verdict because it's going to be used to replace a lot of tools we currently use.

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 18 Nov 2010, 02:48 PM
Hi Jarod,

The ObjectDataSource needs to be connected to a business logic class. In your case you have to set the ObjectDataSource to a class like the one in the following code snippet instead of a entity class.

class MyBusinessLogic
{
    public List<MyDataClass> GetDataByDate(DateTime date)
    {
        //TODO get data by date
        return new List<MyDataClass>();
    }
 
    public List<MyDataClass> GetDataByName(String name)
    {
        //TODO get data by name
        return new List<MyDataClass>();
    }

      public List<MyDataClass> GetAllData()
      {
           //TODO get data by name
           return new List<MyDataClass>();
      }

}
This way you will provide a data that is related to your report logic and you can filter your data through a Report Parameter directly in the datasource.

You can find additional information on the topic in the How to: Bind to a BusinessObject help article.

Greetings,
Peter
the Telerik team
See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
Tags
General Discussions
Asked by
Jarod
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or