You need to sign in to do that
Don't have an account?
Qin Lu
Specify column width dynamically in visual force page
I have a page using apex:repeat to generate the content dynamically. The page code is like the following
<apex:pageBlock >
<apex:repeat value="{!Categories}" var="category">
<apex:pageBlockSection title="{!category}" columns="1">
<apex:pageBlockTable value="{!AcctListByCategory[category]}" var="fa" title="category">
<apex:repeat value="{!fieldListByCategory[category]}" var="field">
<apex:column value="{!fa[field]}" >
</apex:column>
</apex:repeat>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:repeat>
</apex:pageBlock>
Because each category the number of fields are different, some has 4 columns and some has 5 columns. So the columns in pageBlockTables are not in line. I want to figure out a way to set the first 2 column and the last one column width to a fixed number, so the whole page looks better. I understand that we can use <apex:column width="120"> to set the column width. But because my page dynamically rendering the columns, I don't know how I can figure out the first 2 columns and last column and set the width. Any idea is appreciated!
<apex:pageBlock >
<apex:repeat value="{!Categories}" var="category">
<apex:pageBlockSection title="{!category}" columns="1">
<apex:pageBlockTable value="{!AcctListByCategory[category]}" var="fa" title="category">
<apex:repeat value="{!fieldListByCategory[category]}" var="field">
<apex:column value="{!fa[field]}" >
</apex:column>
</apex:repeat>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:repeat>
</apex:pageBlock>
Because each category the number of fields are different, some has 4 columns and some has 5 columns. So the columns in pageBlockTables are not in line. I want to figure out a way to set the first 2 column and the last one column width to a fixed number, so the whole page looks better. I understand that we can use <apex:column width="120"> to set the column width. But because my page dynamically rendering the columns, I don't know how I can figure out the first 2 columns and last column and set the width. Any idea is appreciated!
E.g.
All Answers
E.g.