0
votes

In the Visual Studio Telerik Reporting Designer, the Data Explorer pane shows all data sources and their members for drag-and-drop to the designer. We have reports that we are inheriting from a base report, however. In this case, the Data Explorer is showing the data source(s) of the base report (objectDataSource.DataSource = typeof(BaseViewModel)) rather than the child report (objectDataSource.DataSource = typeof(ChildViewModel)) that is currently open in the designer. Is there a way to get the Data Explorer to instead show the data sources of the child report?

Here is our relevant code:

public partial class BaseReport
{
    private void InitializeComponent()
    {
        objectDataSource = new Telerik.Reporting.ObjectDataSource();
        objectDataSource.DataMember = "GetRecords";
        objectDataSource.DataSource = typeof(BaseViewModel);
        objectDataSource.Name = "objectDataSource";
        DataSource = this.objectDataSource;
    }

    protected Telerik.Reporting.ObjectDataSource objectDataSource;
}

public class BaseViewModel
{
    ...
    // without this dummy method, an exception is thrown in Data Explorer
    public IEnumerable<string> GetRecords()
    {
        return new List<string>();
    }
    ...
}

public partial class ChildReport : BaseReport
{
    public ChildReport()
    {
        InitializeComponent();
        objectDataSource.DataSource = typeof(ChildViewModel);
    }
}

public class ChildViewModel
{
    ...
    public IEnumerable<MyRecord> GetRecords()
    {
        return GetMyRecords();
    }
    ...
}
1

1 Answers

0
votes

Hmm, seems to be a known issue with the Designer.

When the report inherits from a custom class instead of Telerik.Reporting.Report you will lose the design-time support for this report in the Visual Studio report designer. Thus, we recommend to inherit from the default Telerik.Reporting.Report class while designing and saving the report. Once you are done you can change the inheritance to apply your custom class as a template.

https://www.telerik.com/forums/report-inheritance#pckM3wbuxESVkRVB3icPWA