在 Telerik Reporting Visual Studio Data Explorer 中显示 child class 的数据源
Show data source(s) of child class in Telerik Reporting Visual Studio Data Explorer
在 Visual Studio Telerik 报表设计器中,数据资源管理器窗格向设计器显示 drag-and-drop 的所有数据源及其成员。但是,我们有从基础报告继承的报告。在这种情况下,数据资源管理器显示基础报表 (objectDataSource.DataSource = typeof(BaseViewModel)
) 的数据源,而不是当前在设计器中打开的 child 报表 (objectDataSource.DataSource = typeof(ChildViewModel)
)。有没有办法让数据资源管理器改为显示 child 报告的数据源?
这是我们的相关代码:
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();
}
...
}
嗯,这似乎是 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
在 Visual Studio Telerik 报表设计器中,数据资源管理器窗格向设计器显示 drag-and-drop 的所有数据源及其成员。但是,我们有从基础报告继承的报告。在这种情况下,数据资源管理器显示基础报表 (objectDataSource.DataSource = typeof(BaseViewModel)
) 的数据源,而不是当前在设计器中打开的 child 报表 (objectDataSource.DataSource = typeof(ChildViewModel)
)。有没有办法让数据资源管理器改为显示 child 报告的数据源?
这是我们的相关代码:
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();
}
...
}
嗯,这似乎是 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