开发者

RLDC Expression Editor Custom Code

I'm making a .rldc report in local mode, and I'm having trouble figuring out how format my data. For one item field in a data source, the type is a class that has a unit length and a unit type. I'm wondering if it's possible in the expression editor to access each of these elements of the object I pass in. Or will I have to pass in each property of the class separately. Let me know if I need to explain anything better.

Here's the class I'm trying to access

public class Measurement
{
    float value;
    Unit unit;

    public float Value
    {
        get { return value; }
        set { this.value = value; }
    }
    public Unit Unit
    {
        get { return unit; }
        set { unit = value; }
    }
}

And here is what I have for the expression in the text box

<Value>=Fields!Weight.Value.Value</Value>

This is the repo开发者_运维知识库rt's data set's section relevant to this

<Field Name="Weight">
   <DataField>Weight</DataField>
   <rd:TypeName>NewCalculator.Logic.Units.Measurement</rd:TypeName>
</Field>

Thanks


It is no problem for the report generator to render objects with properties - you won't get intellisense support though. This does not work in version 10 of the reporting assembly.

Specify the field:

<Field Name="SomeClass"><DataField>SomeClass</DataField></Field>

Get the value (assuming your SomeClass has an Id property):

<Value>=Fields!SomeClass.Value.Id</Value>

or even

<Value>=Fields!SomeClass.Value.X.Y.Z.Id</Value>

if your class hierarchy goes like that.

Edit:

Let's assume you have a class Body:

public class Body { public Measurement Weight { get; set; } ... }

If you bind your dataSource like this:

ReportDataSource rdsBodies = new ReportDataSource("Bodies",
  new Body[] { new Body(), new Body() });
localReport.DataSources.Add(rdsBodies);

and specify your <DataSet> like this:

<DataSet Name="Bodies">
  <Fields>
    <Field Name="Weight"><DataField>Weight</DataField></Field>
  </Fields>
  <Query>
    <DataSourceName>DS</DataSourceName>
    <CommandText>Bodies</CommandText>
  </Query>
</DataSet>

the value

<Value>=Fields!Weight.Value.Value</Value>

should render without errors if it is inside a List or Table with

<DataSetName>Bodies</DataSetName>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜