The Cross Band element is a very handy tool for building dynamic tables. But many users are challenged by the absence of the implemented ability to calculate totals for cross bands. Actually, you can solve this task using scripts and it won’t be more difficult than if any special approach for this exists.
To calculate totals it is needed to do the following:
- In CommonScript of the document, declare a variable where the summing will be performed:
- In GenerateScript of Detail, which includes CrossBand set the counter to zero:
lineSumm = 0;
- In GenerateScript of TextBox that represents a column, add summing (where dataBand1[(string)GetData("Data.Columns.Name")] – an expression that is displayed in a cell):
lineSumm += (double)dataBand1[(string)GetData("Data.Columns.Name")];
You can find a sample here: http://www.perpetuumsoft.com/Support/samples/CrossBandTotals.zip
- Set binding for Value of TextBox, that is located in the cell for the total to get expression from the lineSumm variable.