我有一个未绑定的 XtraReport,它有一个子报表控件,其中包含另一个报表。我将使用架构定义字段的报表称为“未绑定”,但实际上并未绑定到任何数据集,我使用数据访问层创建一个数据表,然后将该对象传递到报表的 DataSource 属性。
所以,我有以下代码:
// (...) Get the data from the db and fill a DataTable
if (table.Rows.Count > 0)
{
report.DataSource = table;
// (...) Get the data from the db and fill a DataTable for the subreport
report.SubPurchaseOrder.Report.DataSource = tableSubReport;
report.ShowPreviewDialog();
}
else
{
MessageBox.Show("No data to show.");
}
但是使用这种方法得到的子报告打印得非常奇怪(看看 附加 pdf,抱歉它是西班牙语,但我想你明白了)。
我已经阅读了 DevExpress 文档,也许我没有得到正确的方法,所以我向您提出的问题是如何创建一个包含一个或多个子报告的报告,但我必须使用外部的某些流程提供数据来填充它们报告,例如数据访问层?
如果问题表述不正确或缺少更多信息,请告诉我。
编辑:
我在此处上传了一个包含问题报告的示例项目。
我尝试过使用某种参数。在子报表控件的 BeforePrint 事件中,我尝试了:
((XRSubreport)sender).ReportSource.FilterString = "[IdPO_RO] = " + _idPurchaseOrder;
当然
((XRSubreport)sender).ReportSource.Parameters["Id"].Value = _idPurchaseOrder;
,对于第二个,我添加了一个参数和与第一个相同的过滤字符串,但使用了该参数。
I have an unbound XtraReport that has a subreport control which contains another report. I call "unbound" to a report that has the definition of the fields using a schema but not actually bound to any DataSet, I create a DataTable using a Data Access Layer and then pass that object to the DataSource property of the report.
So, I have the following code:
// (...) Get the data from the db and fill a DataTable
if (table.Rows.Count > 0)
{
report.DataSource = table;
// (...) Get the data from the db and fill a DataTable for the subreport
report.SubPurchaseOrder.Report.DataSource = tableSubReport;
report.ShowPreviewDialog();
}
else
{
MessageBox.Show("No data to show.");
}
But what I get using this approach is the subreport printed very oddly (take a look at the attached pdf, sorry it's in spanish but I think you get the idea).
I've read the DevExpress documentation and maybe I'm not getting the approach right, so my question to you is how to create a report that has one or more subreports but I have to provide the data to fill them using some process external to the reports, such as a Data Access Layer?
Please let me know if the question is not stated correctly or lacks of more info.
EDIT:
I uploaded a sample project with the report with problem here.
I've tried to use parameters of some kind. In the BeforePrint event of the subreport control, I tried:
((XRSubreport)sender).ReportSource.FilterString = "[IdPO_RO] = " + _idPurchaseOrder;
and
((XRSubreport)sender).ReportSource.Parameters["Id"].Value = _idPurchaseOrder;
Of course, for the second, I added a parameter and the filter string the same as the first but using the parameter.
发布评论
评论(1)
我可以解决这个问题。
造成这种情况的原因是我分配给了错误的对象。这一行:
应该是:
所以简单的解释是我使用另一个属性来引用子报表控件(XRSubreport)中包含的报表。
I could solve the problem.
The cause for this was that I was assigning to the wrong object. This line:
should be:
So the brief explanation is that I was using another property to refer to the report contained in the subreport control (XRSubreport).