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 destroyColWidth: 70
cloneColWidth: 70 cloneColWidth: 70
elements:
'.js-tableHead': 'tableHead'
events: events:
'click .js-sort': 'sortByColumn' 'click .js-sort': 'sortByColumn'
@ -167,6 +164,7 @@ class App.ControllerTable extends App.Controller
for key, value of data.headerWidth for key, value of data.headerWidth
@headerWidth[key] = value @headerWidth[key] = value
if !@availableWidth
@availableWidth = @el.width() @availableWidth = @el.width()
if @availableWidth is 0 if @availableWidth is 0
@availableWidth = @minTableWidth @availableWidth = @minTableWidth
@ -837,7 +835,7 @@ class App.ControllerTable extends App.Controller
roundingLeftOver = availableWidth - @getHeaderWidths() 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) # 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 @headers[@headers.length - 1].displayWidth = @headers[@headers.length - 1].displayWidth + roundingLeftOver
@storeHeaderWidths() @storeHeaderWidths()
@ -872,7 +870,7 @@ class App.ControllerTable extends App.Controller
setHeaderWidths: => setHeaderWidths: =>
@calculateHeaderWidths() @calculateHeaderWidths()
@tableHead.each (i, el) => @$('.js-tableHead').each (i, el) =>
el.style.width = @headers[i].displayWidth + 'px' el.style.width = @headers[i].displayWidth + 'px'
storeHeaderWidths: -> storeHeaderWidths: ->
@ -885,7 +883,13 @@ class App.ControllerTable extends App.Controller
onResize: => onResize: =>
@availableWidth = @el.width() @availableWidth = @el.width()
localDelay = =>
localSetHeaderWidths = =>
@setHeaderWidths() @setHeaderWidths()
App.QueueManager.add('tableRender', localSetHeaderWidths)
App.QueueManager.run('tableRender')
@delay(localDelay, 200, 'table-resize-finish')
stopPropagation: (event) -> stopPropagation: (event) ->
event.stopPropagation() event.stopPropagation()

View file

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