【问题标题】:Show data source(s) of child class in Telerik Reporting Visual Studio Data Explorer在 Telerik Reporting Visual Studio Data Explorer 中显示子类的数据源
【发布时间】:2018-06-08 14:37:02
【问题描述】:

在 Visual Studio Telerik 报表设计器中,数据资源管理器窗格显示所有数据源及其成员,以便拖放到设计器。但是,我们有从基础报告继承的报告。在这种情况下,数据资源管理器显示的是基础报表 (objectDataSource.DataSource = typeof(BaseViewModel)) 的数据源,而不是当前在设计器中打开的子报表 (objectDataSource.DataSource = typeof(ChildViewModel))。有没有办法让数据资源管理器显示子报表的数据源?

这是我们的相关代码:

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();
    }
    ...
}

【问题讨论】:

    标签: c# visual-studio telerik-reporting


    【解决方案1】:

    嗯,似乎是 Designer 的一个已知问题。

    当报表继承自自定义类而不是 Telerik.Reporting.Report 您将失去设计时支持 Visual Studio 报表设计器中的此报表。因此,我们推荐 从默认 Telerik.Reporting.Report 类继承而 设计和保存报告。完成后,您可以更改 继承以将您的自定义类应用为模板。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-13
      • 1970-01-01
      相关资源
      最近更新 更多