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

Column Resizing

Open mikeerickson opened this issue 10 years ago • 19 comments

Is there a feature for resizing columns?

mikeerickson avatar Mar 30 '16 22:03 mikeerickson

@mikeerickson, this issue is duplicated with #187. And I hope to support this feature in future. But There's no schedule, because I have another bugs or features need to do.

PR is welcome :+1:

Thanks :)

AllenFang avatar Mar 31 '16 01:03 AllenFang

Thanks for quick reply, greatly appreciated. I have forked repo and will have a look. I have implemented resizing on default tables.

mikeerickson avatar Mar 31 '16 01:03 mikeerickson

@mikeerickson, that's awesome, it's hard to implement, because the column with on bootstrap table is hard to control(include, resizing and different browser etc.)

Anyway, I'm glad that you can give any contribution :)

AllenFang avatar Mar 31 '16 02:03 AllenFang

No worries! I have internal vested interest, so the time allotted will be justified. I will begin on this in the morning.

mikeerickson avatar Mar 31 '16 02:03 mikeerickson

Really Thanks :)

AllenFang avatar Mar 31 '16 02:03 AllenFang

+1

yichingwu avatar Aug 31 '16 03:08 yichingwu

Looking forward to it 👍

Rosaniline avatar Aug 31 '16 03:08 Rosaniline

@mikeerickson any updates on this?

oeph avatar Oct 20 '16 08:10 oeph

Any updates?? Need Help

TejashreeD avatar Dec 19 '16 10:12 TejashreeD

There are two PR is opend, but still have some issue we need to solve firstly and I also want to find a best solution for resizing. Sorry for I can't give any promise for when I can got this job done.

AllenFang avatar Dec 20 '16 15:12 AllenFang

hi,

somehow i managed the resizing with jquery resize plugin.. in componentDidMount i wrote this.. for every column seperately.. i know its not a very clean approach, but it works

 componentDidMount:function(){

 $(".table-header .table th:eq(2)" ).resizable({
	 minWidth: 28,
	alsoResize: ".table-container .table th:eq(2), .table-container .table td:eq(2)"});

$(".table-header .table th:eq(3)" ).resizable({
	 minWidth: 28,
	 alsoResize: ".table-container .table th:eq(3), .table-container .table td:eq(3)"});
  
$(".table-header .table th:eq(5)" ).resizable({
	 minWidth: 28,
	 alsoResize: ".table-container .table th:eq(5), .table-container .table td:eq(5)"});
  
},

and so on for 8 columns..

ssjogus avatar Feb 28 '17 05:02 ssjogus

For other folks trying to do this: I used ssjogus's approach with jquery-ui resizable, however, it didn't worked well, e.g. when data are loaded after resizing column, column's width was reseted. I made it work by storing column width in state via resize callback:

$(".table-header .table th:eq(2)" ).resizable({
	minWidth: 28,
        handles: 'e',
        resize: (event, ui) => {
          this.setState({ columnWidth: ui.size.width });
        } 
});

and using this as width prop for column element:

<TableHeaderColumn
  dataField="starts_at"
  width={`${this.state.width}px`}
>...

Another advantage of holding column width in state is that you may e.g. store widths in cookies to remember them for next session.

Still, this is just a hack to make it work and I am also looking forward to resizable columns being native feature of react-bootstrap-table

MichalRemis avatar Oct 03 '17 14:10 MichalRemis

react-bootstrap-table already stop develop new feature and move to react-bootstrap-table2. we will consider to implement resize feature in react-bootstrap-table2 thanks

AllenFang avatar Oct 05 '17 12:10 AllenFang

hey @MichalRemis I couldn't get your solution to work :(, is table-header CSS class something you've defined yourself?

andrecp avatar Dec 14 '17 00:12 andrecp

Can some one please share column resizing example.

bhaveshbhatkar avatar Jan 19 '18 05:01 bhaveshbhatkar

Is there a solution to this issue?

Lithik avatar Feb 09 '18 14:02 Lithik

Ok guys I made JSFiddle example of my approach with jquery-ui resizable (dont forget to include jquery,jquery-ui and also jquery-ui-css). You store widths of columns in the state (nice side effect is that you may e.g. store widths in cookies to remember them between refreshes). I can became tricky when using horizontal scrollbar, but is is doable by tweaking styles/widths.

https://jsfiddle.net/1s8reLw1/14/

MichalRemis avatar Feb 13 '18 20:02 MichalRemis

is the column resizing feature available now in react-bootstrap-table-next ?

anurag060 avatar Oct 07 '19 13:10 anurag060

https://codesandbox.io/s/react-bootstrap-resizable-column-znqj8

Resizable Colum for react-bootstrap

rachitpsolanki avatar Oct 22 '20 10:10 rachitpsolanki