Dynamic Query - Columns automatically resize based on Result

Stimulsoft Reports.NET discussion
ollie283
Posts: 6
Joined: Fri May 20, 2016 9:14 am

Dynamic Query - Columns automatically resize based on Result

Post by ollie283 »

Hi Peeps,

This may of been asked before and I apologize if it has. Basically I would like to know whether it was possible (and if so, how) for the columns on my report to automatically resize at run-time based on the results pulled back from my dynamic SQL query. As it stands, when I view the data of my SQL Query it will add/remove columns depending on the data results brought back. I would like to replicate this in my report. I know you can set conditions, however it is not suited for my purpose.

Any help would be appreciated :)

Cheers,
Ollie
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by Alex K. »

Hello,

Can you please describe your task in more details. Also, can you please provide a more information about your dynamic SQL query.
Also, please check the sample project in the attachment, which show how to create report with the necessary data, columns from code.

Thank you.
Attachments
CreateReportInCode.zip
(11.73 KiB) Downloaded 151 times
ollie283
Posts: 6
Joined: Fri May 20, 2016 9:14 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by ollie283 »

I am trying to make it so that the report adjusts to the results of the query. So for e.g. If my query brings back columns A,B,C,D then the report adjusts for that and fills out those columns. Like wise if the query brought back just A,B,C it would respectively fit. Please see my screenshot. The dynamic query basically looks to see if the "User Field" columns are being used or not within the DB. So if you look at the screenshot "Query Results" the highlighted columns are User Translation 1 and 2. However sometimes it may be more and i need the report to basically mirror exactly the results of the query, so adjusting the size according to the results.

Hope this makes some sense.
Attachments
Query Results
Query Results
Capture3.JPG (138.15 KiB) Viewed 3053 times
Dynamic IF Query Example
Dynamic IF Query Example
Capture2.JPG (67.87 KiB) Viewed 3053 times
Columns in Presented in Report
Columns in Presented in Report
Capture1.JPG (24.14 KiB) Viewed 3053 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by Alex K. »

Hello,

As a way, please try to use the additional data source for these values and relation between tables. And use the master-detail construction with Cross-Data component.

Thank you.
Attachments
ReportSample.mrt
(20.92 KiB) Downloaded 149 times
ollie283
Posts: 6
Joined: Fri May 20, 2016 9:14 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by ollie283 »

Hi,

You will have to excuse my lack of knowledge, but I am quite new to building reports in this software. So could you try the best you can to explain it in layman's terms.

Cheers
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by Alex K. »

Hello,

Can you please send us a test data, we will try to prepare a sample for you.

Thank you.
ollie283
Posts: 6
Joined: Fri May 20, 2016 9:14 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by ollie283 »

Please find attached a zipped document that contains a script which populates your DB with test data. And my dynamic query.

Thanks
Attachments
script.zip
Test Data Files
(3.5 KiB) Downloaded 129 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by Alex K. »

Hello,

Please check the sample report in the attachment.

Thank you.
Attachments
Report_modified.mrt
(16.75 KiB) Downloaded 315 times
ollie283
Posts: 6
Joined: Fri May 20, 2016 9:14 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by ollie283 »

Hi Aleksey,

Sorry for the late reply, been tied up at work lately. However I am now back to working on this report. Thanks for providing the sample report. I think I have get the jist of it. However I can not see why it is not adding the additional columns. As per the attached screenshot, it expanded up to the country field but no further. Do you know why this is?

Cheers,

Ollie
Attachments
No additional columns showing
No additional columns showing
Capture.PNG (10.46 KiB) Viewed 3021 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamic Query - Columns automatically resize based on Re

Post by Alex K. »

Hello,

Can you please send us a sample with test data which reproduces the issue for analysis.

The sample from previous posts does not contains a DateOfBirth column.

Thank you.
Attachments
Capture.PNG
Capture.PNG (37.01 KiB) Viewed 3018 times
Post Reply