Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Dynamic Columns Post Reply Post New Topic
Author Message
moontide
Groupie
Groupie
Avatar

Joined: 23 Feb 2011
Online Status: Offline
Posts: 78
Quote moontide Replybullet Topic: Dynamic Columns
     Posted: 08 Mar 2012 at 5:46am
I am working on a report that is going to have dynamic columns and there are about 50 columns and so I am thinking if
I use array variables with 5 columns and split them in multiple group sections e,g group 2a, group 2b, group 2c and so on.
 
 grp 2a         col1    col2     col3     col4      col5
  row1             1       2         3         4          0
  row2             0       5         0         8          0 
 
 
grp 2b          col1   col2     col3      col4     col5
row 1              1       1        2          3        4
row2               0       5        0          8        0
 
 
if col1, col3 or col5 has no data then it will show '0' else show value.
 
Is this possible using array variables? Please let me know what is the best approach for dynamic columns.  Thanks and will appreciate any suggestions
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Mar 2012 at 8:39am
dynamic...truly dynamic columns in CR don't work.
 
CR needs / will validate the schema of the data being passed in against the schema of the report.  And to be truly dynamic, you would be returning the data from a stored proc (otherwise the values are always there).
 
So, what's a report writer to do?
 
My solution, is to return the columns, always named the same, and if the names are dynamic to include the values in the same table or another table, then have CR display the correct title.
 
with the procedure that fetches the data, you can ensure that every cell is 0 or a value, or you can the report convert NULLs to their default.
 
Now, onto the grouping issue so that the 50 columns fit on 1 page.
 
What I think you are after is multiple rows of display to represent 1 row in the data... If you want the data to be displayed as all of columns 1-10 together and then 11-20, and not interleaved, the only idea that comes to mind is subreports.  That will give you the information for a 'group' of columns as a distinct set of data.
 
The way around the subreport would be to break your returning dataset into shorter rows with a code to signify which group of columns it belongs to, then you could display these new shorter records however you want as you can use conditional suppression to hide/display the columns correctly, and since you have grouped them as you want, you can display them as you want.
 
Hopefully, I am on the right track with my answer.
 
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum