Home
Analytics
Dynamically Change Column width (Cross Tab)
gaby390
Hi. I am trying to dynamically change the width of a column (to 0in), but till now I have not found any solutions. Does anyone know if there is any solution to this problem?
Thank you!
Find more posts tagged with
Comments
gaby390
Ideally would be to make this using a script.
mwilliams
Can you explain more about what you're wanting to do? In what situation do you have a column that you want to make the width 0? Posting a sample made from the sample database would be very helpful. I can edit the design and send it back to you.
gaby390
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="79416" data-time="1309451016" data-date="30 June 2011 - 09:23 AM"><p>
Can you explain more about what you're wanting to do? In what situation do you have a column that you want to make the width 0? Posting a sample made from the sample database would be very helpful. I can edit the design and send it back to you.<br /></p></blockquote>
<br />
It's a bit hard right now to send one sample. I just wanted to make a column of a group 0, when a parameter has a certain value ("unset"). I have the group made out of 4 values, and it is easier to hide the corresponding column when a parameter has that certain value. <br />
The other solution is to just have many tables that are hidden when the corresponding parameters are not set.
mwilliams
In a crosstab, you can make a cell disappear with the following script in the onCreate method of the crosstab:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function onCreateCell( cellInst, reportContext )
{
if (cellInst.getCellID() == cellID#){
cellInst.getStyle().setDisplay("none")
}
}
</pre>
MKI
@mwilliams
The solution does not work if the output format is excel. It would be nice if we can change width from the script
mwilliams
What determines when you want to hide the column? If it doesn't depend on data for a dataSet, you can put something like this in your onPrepare of the crosstab:
function onPrepareCrosstab( crosstab, reportContext )
{
reportContext.getDesignHandle().getElementByID(headerCellID).setStringProperty("width","0px");
reportContext.getDesignHandle().getElementByID(measureCellID).setStringProperty("width","0px");
}
MKI
@mwilliams
Thank you:)
Your solution works perfectly
sschmidt.evalue
<p>Great, but onPrepare is too early in the processing to work for me. My determining factor comes from a dataset. That hasn't been processed yet when onPrepare runs. I need a solution that occurs in onCreate or onRender.</p><p> </p><p>Here's the sequence of my programming:</p><p> </p><ul class='bbcol decimal'><li>In the report initialize scripting: reportContext.setPersistentGlobalVariable("SHOWTF","false");<span> </span>// default<br />
</li><li>In the data set onFetch: if ( [my specific condition] ){reportContext.setPersistentGlobalVariable("SHOWTF","true");}<br />
</li><li>In onPrepareCrosstab: if ( reportContext.getPersistentGlobalVariable("SHOWTF") == "false"){ reportContext.getDesignHandle().getElementByID( [topheadercellID] ).setStringProperty("width","0px"); <div>reportContext.getDesignHandle().getElementByID( [headercellID] ).setStringProperty("width","0px");</div> <div>reportContext.getDesignHandle().getElementByID( [dimensioncellID] ).setStringProperty("width","0px"); }</div></li></ul><div>This last part executes 100% of the time because the onFetch of the dataset hasn't been run yet when the onPrepareCrosstab executes. It ALWAYS hides my column, even when I don't want it to.</div><div> </div><div>Some logging shows that the global variable DOES get set by the time onCreate or onRender rolls through. However, the setStringProperty does NOT appear to work within those contexts.</div>
mwilliams
<p>You might look into this. The Data Engine is a private API that has been exposed, so its availability might be limited in the most recent release and future releases. I've not tried with the latest release to see if it's still there. Either way, this would allow you to process your dataSet data in the beforeFactory, meaning you could know by the onPrepare what you need to know.</p><p> </p><p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/822-data-engine-api-to-check-data-set-values/'>http://developer.actuate.com/community/forum/index.php?/files/file/822-data-engine-api-to-check-data-set-values/</a></p>
;
Tarun Suneja
<div>Hi,</div>
<p> </p>
<p>I have used above script to hide the columns but <span style="font-family:Arial, sans-serif;font-size:12px;">the header is mess, they don't shrink.</span></p>
<div>[sharedmedia=core:attachments:10452]</div>
<div>[sharedmedia=core:attachments:10451]</div>
mwilliams
<p>Hi Tarun,</p>
<p> </p>
<p>Based on what you're doing in this test report, your easiest solution might just be to create three different crosstabs and show/hide the proper ones based on your parameter values. The dropped crosstabs would never be created, so for large reports, this would even save you some time.</p>
JayanthiS
<p>Hi Michael,</p>
<p> </p>
<p><span style="font-size:14px;"><span style="font-family:arial, helvetica, sans-serif;">I have used crosstab in my report, and need to hide the column based on dataset value. <span style="color:rgb(40,40,40);">The column gets hide but </span><span style="color:rgb(40,40,40);">the header is mess, they don't shrink.</span>Could you please provide some sample report on how to hide a column in crosstabs? </span></span></p>
JFreeman
<p>How are you currently hiding the crosstab column?</p>
<p>Most likely, you need to add scripting to also set the header cell's Display value to none.</p>
JayanthiS
<p>Hi Jesse, </p>
<p> </p>
<p>Thanks for your reply, I have attached the sample crosstab report in this, I want to hide all chart columns in the crosstab element.</p>
<p>I have tried by doing in visibility condition and by using script in it but still the columns are getting shrinked.</p>
<p> </p>
<p>Could you please provide some solutions for this.</p>
<p> </p>