Aggregate types can be used in data-bound PrintDocument without the need to declare them in the document's aggregates collection (Aggregates).
For instance, if "Balance" is a data field in a data-bound document, the following RenderText can be used to print the total balance for the dataset:
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
Dim rt As New RenderText("[Sum(""Fields!Balance.Value"")]") |
C# コードの書き方
C# |
コードのコピー
|
---|---|
RenderText rt = new RenderText("[Sum(\"Fields!Balance.Value\")]"); |
The following new properties and methods were added to the DataSet and C1DataBinding types to support this feature:
Class | Member | Description |
---|---|---|
C1DataBinding | Name property | Gets or sets the name of the current C1DataBinding. That name can be used in aggregate functions to indicate which data binding the aggregate refers to. |
DataSet | Name property | Gets or sets the name of the current DataSet. That name can be used in aggregate functions to indicate which data set the aggregate refers to. |
All aggregate functions have the following format:
AggFunc(expression, scope)
where:
For example, if a dataset has the following fields, ID, GroupID, SubGroupID, NAME, Q, and records are grouped by GroupID and SubGroupID, the following document can be created:
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
Dim doc As New C1PrintDocument() Dim raGroupId As New RenderArea() ' 必要に応じてraGroupIdプロパティを設定します。 raGroupID.DataBinding.DataSource = dataSet raGroupID.DataBinding.Name = "GroupID" raGroupID.DataBinding.Grouping.Expressions.Add("Fields!GroupID.Value") Dim raSubGroupID As New RenderArea() ' 必要に応じてraSubGroupIDプロパティを設定します。 raSubGroupID.DataBinding.DataSource = dataSet raSubGroupID.DataBinding.Grouping.Expressions.Add("Fields!SubGroupID.Value") raGroupID.Children.Add(raSubGroupID) Dim raDetail As New RenderArea() ' 必要に応じてraDetailプロパティを設定します。 raDetail.DataBinding.DataSource = dataSet raSubGroupID.Children.Add(raDetail) ' Qフィールドの値を表示します。 Dim rtQ As New RenderText() rtQ.Text = "[Fields!Q.Value]" raDetail.Children.Add(rtQ) ' ネストされたグループ(SubGroupID)のQフィールドの合計を表示します。 Dim rtSumQ1 As New RenderText() rtSumQ1.Text = "[Sum(""Fields!Q.Value"")]" raDetail.Children.Add(rtSumQ1) ' GroupIDのQフィールドの合計を表示します。 Dim rtSumQ2 As New RenderText() rtSumQ2.Text = "[Sum(\"Fields!Q.Value\", "\"GroupID\"")]" raDetail.Children.Add(rtSumQ2) ' データセット全体のQフィールドの合計を表示します。 Dim rtSumQ3 As New RenderText() rtSumQ3.Text = "[Sum(\"Fields!Q.Value\", "\"DataSet\"")]" raDetail.Children.Add(rtSumQ3) doc.Body.Children.Add(raGroupId) |
C# コードの書き方
C# |
コードのコピー
|
---|---|
C1PrintDocument doc = new C1PrintDocument(); RenderArea raGroupId = new RenderArea(); // 必要に応じてraGroupIdプロパティを設定します。 raGroupID.DataBinding.DataSource = dataSet; raGroupID.DataBinding.Name = "GroupID"; raGroupID.DataBinding.Grouping.Expressions.Add("Fields!GroupID.Value"); RenderArea raSubGroupID = new RenderArea(); // 必要に応じてraSubGroupIDプロパティを設定します。 raSubGroupID.DataBinding.DataSource = dataSet; raSubGroupID.DataBinding.Grouping.Expressions.Add("Fields!SubGroupID.Value"); raGroupID.Children.Add(raSubGroupID); RenderArea raDetail = new RenderArea(); // 必要に応じてraDetailプロパティを設定します。 raDetail.DataBinding.DataSource = dataSet; raSubGroupID.Children.Add(raDetail); // Qフィールドの値を表示します。 RenderText rtQ = new RenderText(); rtQ.Text = "[Fields!Q.Value]"; raDetail.Children.Add(rtQ); // ネストされたグループ(SubGroupID)のQフィールドの合計を表示します。 RenderText rtSumQ1 = new RenderText(); rtSumQ1.Text = "[Sum(\"Fields!Q.Value\")]"; raDetail.Children.Add(rtSumQ1); // GroupIDのQフィールドの合計を表示します。 RenderText rtSumQ2 = new RenderText(); rtSumQ2.Text = "[Sum(\"Fields!Q.Value\", "\"GroupID\"")]"; raDetail.Children.Add(rtSumQ2); // データセット全体のQフィールドの合計を表示します。 RenderText rtSumQ3 = new RenderText(); rtSumQ3.Text = "[Sum(\"Fields!Q.Value\", "\"DataSet\"")]"; raDetail.Children.Add(rtSumQ3); doc.Body.Children.Add(raGroupId); |
When the above document is generated, each instance of the raDetail group will show four values as follows: