Getting all used columns in the report

Stimulsoft Ultimate discussion
Post Reply
bobsov
Posts: 115
Joined: Sun Jan 27, 2013 12:10 am

Getting all used columns in the report

Post by bobsov »

My reports are usually created using wizard mode. In that, report creator can select all or just few columns to report on. Since these reports are large, when actual data is fetched for preview or running the report, I want to get only those columns data that are used in the report. How do I loop through dictionary object and get column names that are used in the report. Please help.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Getting all used columns in the report

Post by Alex K. »

Hello,

You can use the following method:

Code: Select all

StiDataSourceHelper.GetUsedDataSourcesNames()
Thank you.
bobsov
Posts: 115
Joined: Sun Jan 27, 2013 12:10 am

Re: Getting all used columns in the report

Post by bobsov »

That is great to get used data source names. How about actual used columns within that datasource. How do I get that?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Getting all used columns in the report

Post by HighAley »

Hello.

The Data sources should be created before running wizard. And it's possible to select columns in the SQL query only.
So it's impossible to implement such feature. It's better to set necessary fields only.

Thank you.
bobsov
Posts: 115
Joined: Sun Jan 27, 2013 12:10 am

Re: Getting all used columns in the report

Post by bobsov »

Oh no. I was really hoping there is easy way to get used columns. In wizard, we provided more than 50 fields to choose from. Running a query for each of them will be very expensive. It looks like the only good solution would be to not use wizard at all and do same thing outside of reporting and once fields are selected, then redirect user to report designer. Thanks Aleksey. Its not a deal breaker to me.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Getting all used columns in the report

Post by HighAley »

Hello.

After finish of creating report with wizard it's possible that users will need to add of replace some fields. So it's not right to remove fields from Dictionary automatically even if it would be possible.

Thank you.
bobsov
Posts: 115
Joined: Sun Jan 27, 2013 12:10 am

Re: Getting all used columns in the report

Post by bobsov »

That is a great point. And I did think about it. I will have to maintain a collection somehow to keep track of actual fields used whether from wizard or later when report is saved. I own the source code now, so sooner or later I will learn to make this work. If you have an idea how to scan designer to get used fields, let me know.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Getting all used columns in the report

Post by HighAley »

Hello.

There is a method in StiDictionary that removes unused data sources. It's name RemoveUnusedDataSourcesV2().
You could use it to create your method to remove fields.

Thank you.
Post Reply