Page 1 of 2
Dynamic Columns
Posted: Sat Feb 06, 2016 10:52 am
by paullef
Hello,
I am trying to adapt the printtable example, to integrate this in the events of a report. I want to have multiple objects on a page, including a databand which shows all columns of a (dynamic) datatable. I am trying to set this code in the databand/page/report beginrenderevent, and it creates the textboxes but no data is shown. Do I need another event, or what am I doing wrong?
Secondly, can the pagewidth be dynamicly be adjusted to the widht of this databand (with multiple columns)?
Thanks
Paul
dim i as integer
for i = 0 to DataTable.Columns.Count - 1
Dim DataText As New StiText(New RectangleD(i, 0, 10, 0.5))
DataText.Text.Value = "{DataTable." & DataTable.Columns(i).Name & "}"
DataText.Name = "DataText" & i
DataText.Border.Side = StiBorderSides.All
Databand1.Components.Add(DataText)
next
Re: Dynamic Columns
Posted: Mon Feb 08, 2016 7:48 am
by HighAley
Hello.
Sorry, maybe we don't understand your task.
Could you describe your task with multiple objects more detailed with samples?
As about page width, you could set the Segment per Width property of the page. The segment with page width will be added.
Thank you.
Re: Dynamic Columns
Posted: Mon Feb 08, 2016 8:22 am
by paullef
On a part of the report (on a page) I want to report the content of a table, including all fields. This table is dynamic and therefore I must have multiple columns. On the first page of this report, certain statistics must be shown, this is not a dynamic page.
I am trying to adept the columns of the databand in which I want to display these records and fields, by using the beginrenderevent.
Thanks
Paul
Re: Dynamic Columns
Posted: Mon Feb 08, 2016 5:13 pm
by paullef
I have managed to get this working, by adding a addhandler, and using reflection to get dynamicly to the properties of the datatable (and to the fieldinformation).
Thanks
Paul
Re: Dynamic Columns
Posted: Tue Feb 09, 2016 7:11 am
by HighAley
Hello.
Did you try to create the report dynamically in code? Here is a sample.
Also you could look at the Selecting Columns demo report in Dialogs section of our Demo.
Thank you.
Re: Dynamic Columns
Posted: Tue Feb 09, 2016 8:14 am
by paullef
No, I used the beginrenderevent event to add code, for the creation of the fields, and adding a addhandler. The addhandler calls a function which I added in the code part of the report, getting the content of the fields. This is done using reflection, to get the content of the properties of a datasource.
All working.
Thanks
Paul
Re: Dynamic Columns
Posted: Tue Feb 09, 2016 2:16 pm
by HighAley
Hello, Paul.
Good. Let us know if you need additional help.
Thank you.
Re: Dynamic Columns
Posted: Thu Feb 11, 2016 10:26 pm
by jp2code
I believe I am trying to do the same thing.
I have a user supplied boolean parameter
p_boolPrintProfit.
If it is TRUE, the PROFIT column should display.
If it is FALSE, the "PROFIT" column should not display.
HighAley wrote:Hello.
Did you try to create the report dynamically in code? Here is a sample.
DynamicCreateReport.zip
Also you could look at the Selecting Columns demo report in Dialogs section of our Demo.
Thank you.
I've downloaded this example to take a look at it.
It it solves my issue, I will post back.
Re: Dynamic Columns
Posted: Fri Feb 12, 2016 12:58 pm
by HighAley
Hello.
The sample shows how to create a report template in code dynamically.
If you need to hide the component in the report, you could use the
Conditions and disable there
Component is Enabled option.
Thank you.
Re: Dynamic Columns
Posted: Fri Feb 12, 2016 4:10 pm
by jp2code
Thanks!
I followed this up with my own question, to stop hi-jacking this thread.
How to set Report Variable from Visual Studio code?