0

I am generating pdf and word documents. In that displaying the tables using html tags. columns will be different for each records. I want to set width of the column based list count. If list have 3 records i want to display 3 coulumns fit in the table width.(means table width is 100%, then column width should be 100/3). If list has 5 records i want to display 4 columns(here column width should be 100/4). max 7 records. How to set the width dynamically..?

1 Answer 1

0

You can simple check the number of rows in your controller and calculate width .

for ex:

Integer width = 100 / number_of_records;

And then use this variable in you VF/HTML. for ex.

<table>
    <TH>
        <TD width="{!width}">
        <TD width="{!width}">
        <TD width="{!width}">
    </TH>
    <tr>
        <td>First Name</td>
        <td>Last Name</td>
        <td>Gender</td>
   <tr/>
<table/>   
1
  • Hi it's working perfectly for pdf. but word document i am not getting width what i mentioned. Mar 4, 2016 at 7:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .