Dynamically selecting fields to display on report from Form Parameters

Stimulsoft Reports.NET discussion
Post Reply
Tom7
Posts: 21
Joined: Wed Mar 24, 2010 5:22 am
Location: Belfast

Dynamically selecting fields to display on report from Form Parameters

Post by Tom7 »

Hi All

I was wondering if I load up a Stimulsoft Report, that has a Form to collect parameters, and on the Form I have a number of Check Boxes that correspond to the various fields available to display on the report. For example if I have 30 Check Boxes on the Form, and 30 fields on my report, and at the time of running the report I check only 5 of the Check Boxes to display 5 of the fields. I don't think I will have a problem hiding the field from displaying on the report, but what I want to know is, is there any way to dynamically reposition the fields on the report so that the 5 fields I choose all line up close together on the same line.

I know that when designing the report normally, I position on the report where the fields will be, but if I have a report with potentially 30 fields, which stretches over 2 pages when all fields are displayed in the databand, I don't want this to happen when I choose only 5 fields, and if the fields that I choose are not positionally side by side, I don't want huge gaps of white space between them, I want these fields to be lined up together.

Hope this makes sense, and everyone gets an idea of what I am trying to achieve

Any help would be much appreciated

Thanks

Tom

Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

Dynamically selecting fields to display on report from Form Parameters

Post by Brendan »

Are the fields you place on your report just a standard databand where each field is a column?
So you have 5 columns in your databand and you want to let the user choose which ones to display. e.g they want to hide column 2 and 3 and you don't want to be left with something like:

[Col 1] [empty space] [empty space] [Col 4] [Col 5]

something like that?

If so, have a look at the demo application that comes installed with the Reports sdk.
select the 'Dialogs' category along the left and run the 'Selecting Columns' example. This sounds like what you're after.
The trick is using the Dock Style property for your fields by docking them to the left. this way when one field is hidden the field to its right will take its place.
Tom7
Posts: 21
Joined: Wed Mar 24, 2010 5:22 am
Location: Belfast

Dynamically selecting fields to display on report from Form Parameters

Post by Tom7 »

Hi Brendan

Yes this is exactly what I am after

I have had a look at the Dock setting on the columns, but something strange happens on some of them, when I set Dock - Left on my columns some act perfectly, but in other instances when docking a column to the left it will position itself incorrectly in the "Queue", so instead of docking next to the column beside it, it will leapfrog it and dock to another column, in effect mixing up the order of my columns

Hope this makes sense!

Is it anything to do with the width of the columns?
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

Dynamically selecting fields to display on report from Form Parameters

Post by Brendan »

This is caused by the Z index or Tab index of the textbox when you add it to the band. This value is automatically set when a component is added to the band or page.
You can simply change their order by right clicking on the field and selecting any of the following from the 'Order ->' context menu:
Bring to Front
Send to Back
Move Forward
Move Backward
If you need to see the order of the components on the page you can show it by selecting 'Show Order' from the main menu [View -> Show Order]

When you use the Dock property you can think of your fields as being stacked from left to right.
'Send to Back' will move a field to the very left of the stack.
'Bring to Front' will move a field to the top (or right) of the stack.
Move Forward and Move backward will shift the field one place to the left or right.
Tom7
Posts: 21
Joined: Wed Mar 24, 2010 5:22 am
Location: Belfast

Dynamically selecting fields to display on report from Form Parameters

Post by Tom7 »

:biggrin: Nice one Brendan, that looks to have done it for me.

Thanks for your help on this, I know it was a little tricky to explain the situation

Cheers

Tom
Tom7
Posts: 21
Joined: Wed Mar 24, 2010 5:22 am
Location: Belfast

Dynamically selecting fields to display on report from Form Parameters

Post by Tom7 »

Hi All

I have another follow up question on this topic, if I have the page with 30 fields on it when creating in designer, but the user only chooses to view 10 of them on the report, is there anyway of chopping the width of my page when the report is viewed? to only be the width of, minimum A4 Landscape, or maximum, the width the fields need to be displayed on the page.

When I am creating in designer, I have the page width set at something like 100cm, to fit in ALL the available fields, but don't want the report to be this width all the time (only when the user selects to view all the fields)

Anyone any ideas? hope this makes sense what I am trying to achieve!

Thanks

Tom
Anton Lozovskiy
Posts: 135
Joined: Tue Aug 11, 2009 9:38 am

Dynamically selecting fields to display on report from Form Parameters

Post by Anton Lozovskiy »

Hello,

We have made you a simple example that should solve your problem.

Thank you.
Attachments
387.Sample.mrt
(14.81 KiB) Downloaded 441 times
Tom7
Posts: 21
Joined: Wed Mar 24, 2010 5:22 am
Location: Belfast

Dynamically selecting fields to display on report from Form Parameters

Post by Tom7 »

Cheers AntonLoz! looks good
chris.procter
Posts: 32
Joined: Wed Jun 10, 2009 4:48 pm
Location: Edmonton

Dynamically selecting fields to display on report from Form Parameters

Post by chris.procter »

Thanks Brendan; I was just asked how to do this a few minutes ago. :byebye:
Post Reply