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..?

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/>   
  • Hi it's working perfectly for pdf. but word document i am not getting width what i mentioned. – Vijay Kumar Mar 4 '16 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.