bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

Disable columns autocalc width & Resiziable + Fixed table height

Open blacksheriff opened this issue 6 years ago • 18 comments

Thanx for greate component. I've to quastions:

  1. How I can disable auto column width recalc? I've set fixed column width 43px for expamle style in browser showing right "width, but computed width after load data is 59, or 65 or anything else... image

  2. Is it possible to work with resizable columns when height of table is set to fixed value?

blacksheriff avatar Feb 14 '20 13:02 blacksheriff

  1. You can use the class column option to solve your problem: https://live.bootstrap-table.com/code/wenzhixin/1830

  2. Not support: https://bootstrap-table.com/docs/extensions/resizable/#known-issues

wenzhixin avatar Feb 16 '20 03:02 wenzhixin

  1. You can use the class column option to solve your problem: https://live.bootstrap-table.com/code/wenzhixin/1830
  2. Not support: https://bootstrap-table.com/docs/extensions/resizable/#known-issues
  1. Thanx a lot for reply. It's very difficult to make it vith class names, because a have a hundred of tables with hundred of columns. It'l be nice to have a disableRecalc flag in table options if it possible. I have a fixed width in my every column may be i can write smth in inline style?

blacksheriff avatar Feb 17 '20 07:02 blacksheriff

  1. You can use the class column option to solve your problem: https://live.bootstrap-table.com/code/wenzhixin/1830 Unfortunatelly it doesn't help. It recalcs th and td automatically: image

blacksheriff avatar Feb 17 '20 12:02 blacksheriff

If I not mistaken, it can be simple solve with change "width" to "min-width" for bootstrap4 respect that. in line 4199 bootstrap-table.js: style += Utils.sprintf('width: %s; ', (column.checkbox || column.radio) && !width ? !column.showSelectTitle ? '36px' : undefined : width ? width + unitWidth : undefined); Referenced to https://stackoverflow.com/a/23509701:

blacksheriff avatar Feb 17 '20 13:02 blacksheriff

I think we can overwrite the CSS style for this problem. For example:

td.bs-checkbox {
  width: 36px !important;
  min-width: 36px;
}

wenzhixin avatar Feb 18 '20 01:02 wenzhixin

I think we can overwrite the CSS style for this problem. For example:

td.bs-checkbox {
  width: 36px !important;
  min-width: 36px;
}

It should be set for every column for take effect. if column count over 50 it'l be large css file

blacksheriff avatar Feb 18 '20 06:02 blacksheriff

You can try to set table layout: https://live.bootstrap-table.com/code/wenzhixin/1861

wenzhixin avatar Feb 18 '20 06:02 wenzhixin

You can try to set table layout: https://live.bootstrap-table.com/code/wenzhixin/1861

It works with "width: auto !important" in .table class Without it, ,<th> looks fine, but <td> of 50 columns, trying to fit screen border respecting "width 100%" from bootstrap table class css. image and if the other table has no 50 columns, but only 3 it doesn't looks good. image Changing "width" to "min-width" is prefer, i think

blacksheriff avatar Feb 18 '20 07:02 blacksheriff

I've saved my example to show you about "table-layout: fixed; ": https://live.bootstrap-table.com/code/blacksheriff/1865

blacksheriff avatar Feb 18 '20 08:02 blacksheriff

So what about min-width?

blacksheriff avatar Feb 20 '20 06:02 blacksheriff

?

blacksheriff avatar Mar 11 '20 13:03 blacksheriff

@djhvscf i guess your more familiar with css :)

UtechtDustin avatar Mar 11 '20 13:03 UtechtDustin

@djhvscf i guess your more familiar with css :)

My css knowledges is not critical here. Once again, I have many dynamic tables in which from 3 to 50 fields of a given width. Auto-recalculation randomly changes this width, which is not bad, but bootstrap spoils everything - changing width randomly to fit screen, respecting "width 100%". How can I turn off auto-recalculation of columns width, or change the column style in line 4199 of bootstrap-table.js "width" to "min-width". That would help too.

blacksheriff avatar Mar 12 '20 06:03 blacksheriff

@blacksheriff i dont mean your css knowledges :)

UtechtDustin avatar Mar 12 '20 08:03 UtechtDustin

Have you solved your problem?

wenzhixin avatar Jul 09 '20 15:07 wenzhixin

No, I'm still waiting for )

blacksheriff avatar Jul 10 '20 05:07 blacksheriff

td { min-width: 200px !important; }
is ok for me. It is auto td width problem. Thanks

thetphoongon avatar Jun 23 '22 04:06 thetphoongon

I solved the issue with javascript give th a class <th class="th-min-width"></th> and then do

document.querySelectorAll(".th-min-width").forEach(function (el) {
  el.style.minWidth = el.style.width;
});

mak1A4 avatar Nov 04 '23 12:11 mak1A4