Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamic Table Column Sizing based on Dataset Row Data
lotusman
<p>Hi,</p><p> </p><p>I would like to dynamically resize each column width in a table based on the data in the bound dataset (thus I don't know the width until I can access that data in the dataset). Each table will only have 1 row (linked to an outer table element), but I have been unable to dynamically resize the table column width. As far as I can tell, I am encountering a lifecycle issue. It appears that the table column width is set in the onCreate and can't be modified and that the dataset row is not available until after this time. So I have been unable to resize the table.</p><p> </p><p>What I am trying to do is have 4 columns that "total" 100%. Each column is based on a dataset element that has a count. For example</p><p> </p><p>Col A | Col B | Col C | Col D</p><p>
</p><p> 20 | 25 | 30 | 25</p><p> </p><p>So the column A width should be 20 / (20 + 25 + 30 + 25) = 20% (just to make the numbers simple). Column B would be 25%, C = 30% and D = 25%. I am colouring the backgrounds of each column a different colour to graphically illustrate a horizontal "stacked" chart. This is integrated into a larger table and data, thus I can't use a chart here. I almost have it - I have the values displaying, the colours correct, but have been unable to dynamically size the table column width. Anyone have any thoughts?</p><p> </p><p>I also tried adding the 4 data elements into a single column with the display set to Inline, but they don't resize correctly, and I want no whitespace between the elements which I can't seem to achieve so far.</p><p> </p><p>Thanks</p>
Find more posts tagged with
Comments
GLO_FR
<p>[color=rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;]Hi,[/color]<br />
<br />
[color=rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;]You can set a column's width dynamically by selecting the table, going to the script tab, and putting the following in the onCreate script:[/color]</p><pre class="_prettyXprint">this.getColumn(0 based column number).width = "string width" </pre><p><span style="font-size:14px;">just calculate the different size and put them in variables so you can pass them to the script easily.</span></p>
lotusman
<p>Hi,</p><p> </p><p>Thanks for that. I do know I can change it in the table onCreate script. My problem is that I need the data from the dataset to calculate the column widths and that isn't available at the time of the table onCreate.</p><p> </p><p>Thanks</p>
GLO_FR
<p>Hi,</p><p> </p><p>dataset values are available. Put the value in a global variable and that's it.</p><p>Here is an example</p><p> </p>