0

I want to expand this table because I think this table is too narrow. This is an actual screenshot of the image.

enter image description here

and this is my code:

$('#month-auto-depo').DataTable({
      "columns" : [
        {"width": "30%"},
        {"width": null}
      ],
      "searching": false,
      "paging"   : false,
      "ordering" : false,
      dom        : 'Bfrtip',
      buttons    : [
        'csv', 'excel',
      ],
      "scrollX"  : true
});
$('[data-toggle="tooltip"]').tooltip();
3
  • Do you mind adding the html code for the table itself? Commented Dec 20, 2018 at 9:38
  • And you should have simple snippet code Commented Dec 20, 2018 at 9:39
  • I can't, Stack Overflow prevent me to post too much codes. Commented Dec 20, 2018 at 9:42

2 Answers 2

3

Set Width:100% or anything you want on your table tag.

<table class="datatable table" style="width:100%">
Sign up to request clarification or add additional context in comments.

Comments

2

DataTable document (https://datatables.net/examples/basic_init/flexible_width.html) said:

Often you may want to have your table resize dynamically with the page. Typically this is done by assigning width:100% in your CSS, but this presents a problem for Javascript since it can be very hard to get that relative size rather than the absolute pixels. As such, if you apply the width attribute to the HTML table tag or inline width style (style="width:100%"), it will be used as the width for the table (overruling any CSS styles).

So you should set the container contain data table with your width, and data table set inline style style="width:100%" such as

<table id="example" class="display" style="width:100%">

It is enough smart (flexible) to change the table size when window change

Example with container width 80%:

div.container {
        width: 80%;
    }

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.