Files
jikimo_sf/sf_sale/static/js/setTableWidth.js
2024-01-08 16:28:49 +08:00

30 lines
880 B
JavaScript

function setTableWidth() {
let timer = null
const dom = $('.o_list_renderer ')
if(!dom.length) {
timer = setTimeout(setTableWidth, 500)
return
}
const widthTest = '<span id="widthTest" style="width: fit-content"></span>'
$('body').append(widthTest)
clearTimeout(timer)
const tbody_tr = dom.find('tbody').children('tr')
dom.find('thead').children('tr').children().each(function () {
$('#widthTest').text($(this).text())
const width = $('#widthTest').width() + 10
const i = $(this).index()
tbody_tr.each(function () {
if($(this).children().length > 2) {
$(this).children().eq(i).css('min-width', width + 'px')
}
})
})
const resizeEvent = new Event('resize');
window.dispatchEvent(resizeEvent);
}
$(function () {
setTableWidth()
})