【发布时间】: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