让报表从用户自定义的 View 中获取相关的字段

Links of Dev Documentation:

1. Bind a Report to Multiple Data Sources

2. Calculated Fields

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 相关的记录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值