I have a Report with one Detail band, in this Detail band I have one DetailReport
In the DetailReport, I set the ReportPrintOptions.DetailCountOnEmptyDataSource to 10 expecting that if the DetailReport Datasource is empty or not defined, the DetailReport will print 10 detail items.
This does not appear to be the case however. It would appear that the ReportPrintOptions for the DetailReport are dependent on the Master Report Datasource (not it's own DataSource). This is evident when I set the Master Report Datasource to null and then the DetailReport displays 10 items as defined.
Also, if I set ReportPrintOptions.DetailCount = 10 on the DetailReport and there are less then 10 items in the DataSource, I was hoping that still the 10 detail items would be displayed - the first n rows with the items data and the remaining rows with no data. The documentation does not indicated that this value is only effective when there are more datasource items than the specified value (in this case 10).
Can this be clarified or confirmed please?
Thank you for contacting us. The DetailReport's DataSource is set according to the parent report's DataSource. That is why this issue occurs. If you wish to leave the DetailReport's DataSource empty, handle the DetailReport's BeforePrint event and clear the DetailReport's XtraReportBase.DataSource Property.
In this case, the ReportPrintOptions.DetailCountOnEmptyDataSource Property will work correctly.
As for your second question, the ReportPrintOptions.DetailCount Property only allows you to limit DetailBands that are printed in the report, i.e. the DetailCount property cannot be more than the number of records in your DataSource.
Thanks for the prompt reply.
In my Report, I have a datasource 'bindingSource1', in my DetailReport - I have removed this datasource in the designer i.e. set it to '(none)' and set DetailCountOnEmptyDataSource to 10.
In the Preview in VS2010, it correctly shows 10 items.
At runtime in a WinForms PrintControl, it shows just 1 item.
Am I missing something?
Your comments regarding the DetailCount only being the maximum number of items are noted. The documentation could be clearer in this regard.
* It would actually be a good feature to allow this to be greater that the number of items in the datasource as it would enable behaviour that maybe implemented in issue S19637 (i.e. XRCrossBandTable - 'in each band the user might choose the number of lines'). Something like MaxDetailCount and MinDetailCount?
Thank you for your reply. When you assign a real DataSource to your report, this DataSource is also assigned to your DetailReportBand. I have created a sample project that illustrates how to avoid this problem. You will find it in the attachment.
As for your second question, please review the How to print DetailBand a particular amount of times irregardless of the number of records in a report datasource example that illustrates how to implement the behavior you mentioned.
Let me know whether or not my answer helped you resolve the problem. I am looking forward to hearing from you.
In my case, I am using the EF 4.1, I have a different Entity Type (and BindingSource) for the Detail and DetailReport - in designer I can then see what fields are available.
At runtime, the datasource is set for each report bindingSource (which are different), but DetailReport will never have an empty datasource as it has a BindingSource assignd - even though that BindingSource has no datasource. I think I need to explicitly remove the Datasource from the DetailReport to get the desired behaviour.
One last question - DetailCountOnEmptyDataSource - is this supposed to mean a null or undefined datasource, or a datasource that contains no records/values (i.e. is is empty)?
The ReportPrintOptions.DetailCountOnEmptyDataSource Property is applied only if the XtraReportBase.DataSource Property is null. Thus, you should clear the DetailReport's DataSource to make this approach work.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.