Links of Dev Documentation:
1. Bind a Report to Multiple Data Sources
3. Filter Report Data Source via XtraReports Parameters
1. Pass parameter - use primary key(s)
//get value of Stock_ID
protected override void ProvideMoreReportParameters(System.Collections.Generic.Dictionary<string, object[]> results, string parameterName)
{
int[] rowHandles = grdViewMain.GetSelectedRows();
if (rowHandles.Length < 1)
return;
switch (parameterName)
{
case "Stock_ID":
results.Add(parameterName, new object[]{ ((S_Lot)grdViewMain.GetRow(rowHandles[0])).Stock_ID});
break;
}
}
// Add Parameter to the XtraReport
protected override void PrepareXtraReportProperties(XtraReportExWrapper reportWrapper, bool isCtrlPressed)
{
base.PrepareXtraReportProperties(reportWrapper, isCtrlPressed);
Dictionary<string, object[]> parameter = _provider.ProvideReportParameters("Stock_ID");
reportWrapper.AddParameter("prmStock_ID", GetSingleValue(parameter, "Stock_ID"));
}
2. Bind report to your view
2.1 Insert Detail Report
2.2. New DataSource :
3. Filter:
Make sure the parameter is in proper format, switch to the [Text] tab for more checking:
4. Preview Report
总结
优点:用户能够自定义查询 DB 中任意的字段,无需使用 CalculatedField
缺点:这种方法设计的 DetailReport 并不是真正GroupBy 后的子报表,每次只能打印一个 Stock_ID 相关的记录