1

I am using datatables from here. I have made a table from my database. I want to change width of each column in terms of percentage. Any relative code or example can help me?

<table id="example" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th width="60%">Name</th>
            <th width="40%">Position</th>
        </tr>
    </thead> 
    <tbody>
        <tr>
            <td width="60%">ABC</td>
            <td width="40%">DEF</td>
        </tr>
        <tr>
            <td width="60%">XYZ</td>
            <td width="40%">ZYX</td>
        </tr>
    </tbody>
</table>
5
  • try look in their documentation: datatables.net/manual/styling Commented Jul 8, 2015 at 6:31
  • updated my code now @JimiLoe that link i tried and didnt help Akul Commented Jul 8, 2015 at 6:45
  • Have a look at this as well. datatables.net/reference/option/columns.width. Commented Jul 8, 2015 at 7:30
  • Do you mean Table ? Because database is handled by SQL. There's no css involved ! Commented Jul 8, 2015 at 7:34
  • @stevenw00 that works in IE and Firefox but not in chrome Commented Jul 8, 2015 at 9:57

1 Answer 1

1

According to their documentation you can do the following:

$('#example').dataTable( {
  "columns": [
    { "width": "60%" },
    { "width": "40%" },
  ]
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.