Fixed resizing of table by browser window resize. Related to issue #2031.

This commit is contained in:
Martin Edenhofer 2018-11-19 18:43:44 +01:00
parent f2644cd622
commit c6411fd914
2 changed files with 14 additions and 10 deletions

View file

@ -100,9 +100,6 @@ class App.ControllerTable extends App.Controller
destroyColWidth: 70
cloneColWidth: 70
elements:
'.js-tableHead': 'tableHead'
events:
'click .js-sort': 'sortByColumn'
@ -167,6 +164,7 @@ class App.ControllerTable extends App.Controller
for key, value of data.headerWidth
@headerWidth[key] = value
if !@availableWidth
@availableWidth = @el.width()
if @availableWidth is 0
@availableWidth = @minTableWidth
@ -837,7 +835,7 @@ class App.ControllerTable extends App.Controller
roundingLeftOver = availableWidth - @getHeaderWidths()
# but only if there is something left over (will get negative when there are too many columns for each column to stay in their min width)
if roundingLeftOver > 0
if roundingLeftOver > 0 && roundingLeftOver < 10
@headers[@headers.length - 1].displayWidth = @headers[@headers.length - 1].displayWidth + roundingLeftOver
@storeHeaderWidths()
@ -872,7 +870,7 @@ class App.ControllerTable extends App.Controller
setHeaderWidths: =>
@calculateHeaderWidths()
@tableHead.each (i, el) =>
@$('.js-tableHead').each (i, el) =>
el.style.width = @headers[i].displayWidth + 'px'
storeHeaderWidths: ->
@ -885,7 +883,13 @@ class App.ControllerTable extends App.Controller
onResize: =>
@availableWidth = @el.width()
localDelay = =>
localSetHeaderWidths = =>
@setHeaderWidths()
App.QueueManager.add('tableRender', localSetHeaderWidths)
App.QueueManager.run('tableRender')
@delay(localDelay, 200, 'table-resize-finish')
stopPropagation: (event) ->
event.stopPropagation()

View file

@ -1181,7 +1181,7 @@ class Table extends App.Controller
if @el.width() != 0
@elWidth = @el.width()
if @elWidth
tableArguments.minTableWidth = @elWidth
tableArguments.availableWidth = @elWidth
@table = new App.ControllerTable(tableArguments)