frank
frank

Reputation: 1201

bootstrap-table resize column not work if I set columns in javascript

I am using following example to do resizable columns:

https://live.bootstrap-table.com/example/extensions/resizable.html

If I did as the link example, set columns in thead:

<table id="table"

  data-url="json/data1.json"
  data-resizable="true">
  <thead>
    <tr>
      <th data-field="id" data-width="18">ID</th>
      <th data-field="name" data-width="20">Item Name</th>
      <th data-field="price" data-width="25">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  $(function() {
    $('#table').bootstrapTable()
  })

then I can resize the columns.

However if I set columns in js like :

<table id="table"

  data-url="json/data1.json"
  data-resizable="true">

</table>

<script>
  var defaultColumns = [        
        {title: 'Id', field: 'id', width: 180},
        {title: 'Name', field: 'name', width: 100},
        {title: 'Price', field: 'price', width: 180}            
        ];

  $(document).ready(function() {

    $( '#table' ).bootstrapTable(

        {columns: defaultColumns}
    );
  });

Then I cannot resize the columns.

How can I resize the columns if I set the columns in js?

Upvotes: 0

Views: 1800

Answers (1)

Dennis Hern&#225;ndez
Dennis Hern&#225;ndez

Reputation: 122

This is fixed in this pull request

Upvotes: 1

Related Questions