@@ -159,6 +159,7 @@ class Views extends TableView {
159
159
content = (
160
160
< div className = { tableStyles . rows } >
161
161
< table style = { { width : this . state . tableWidth , tableLayout : 'fixed' } } >
162
+ { this . renderColGroup ( ) }
162
163
< tbody > { data . map ( row => this . renderRow ( row ) ) } </ tbody >
163
164
</ table >
164
165
{ footer }
@@ -212,7 +213,7 @@ class Views extends TableView {
212
213
content = String ( value ) ;
213
214
}
214
215
return (
215
- < td key = { name } className = { styles . cell } style = { { width } } >
216
+ < td key = { name } className = { styles . cell } >
216
217
{ content }
217
218
</ td >
218
219
) ;
@@ -221,13 +222,25 @@ class Views extends TableView {
221
222
) ;
222
223
}
223
224
225
+ renderColGroup ( ) {
226
+ return (
227
+ < colgroup >
228
+ { this . state . order . map ( ( { width } , i ) => (
229
+ < col key = { i } style = { { width } } />
230
+ ) ) }
231
+ </ colgroup >
232
+ ) ;
233
+ }
234
+
224
235
handleResize ( index , delta ) {
225
- this . setState ( ( { order, tableWidth } ) => {
236
+ this . setState ( ( { order } ) => {
226
237
const newOrder = [ ...order ] ;
227
- const next = Math . max ( 40 , newOrder [ index ] . width + delta ) ;
228
- const diff = next - newOrder [ index ] . width ;
229
- newOrder [ index ] = { ...newOrder [ index ] , width : next } ;
230
- return { order : newOrder , tableWidth : tableWidth + diff } ;
238
+ newOrder [ index ] = {
239
+ ...newOrder [ index ] ,
240
+ width : Math . max ( 40 , newOrder [ index ] . width + delta ) ,
241
+ } ;
242
+ const tableWidth = newOrder . reduce ( ( sum , col ) => sum + col . width , 0 ) ;
243
+ return { order : newOrder , tableWidth } ;
231
244
} ) ;
232
245
}
233
246
0 commit comments