Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议table新增指定列相同内容行合并功能 #15

Open
lvwenju opened this issue Jan 19, 2024 · 0 comments
Open

建议table新增指定列相同内容行合并功能 #15

lvwenju opened this issue Jan 19, 2024 · 0 comments

Comments

@lvwenju
Copy link

lvwenju commented Jan 19, 2024

前端接触不深,自己写的感觉有点蠢。
搜了tableMerge 不能用了,
搜了 分享:基于aop的方式对table、layer等组件做了增强 https://layui.yuntao.xyz/guide/ 也不能用

自己的代码:
function mergeCell(tableLayId, startRow=3, endRow=100, col) { let table = $('div[lay-id="' + tableLayId + '"]'), rowspan, currentCell; for (let r = startRow; r < endRow; r += rowspan) { currentCell = table.find('tr').eq(r).find('td').eq(col); let firstColumnCell = currentCell.siblings().eq(0); rowspan = 1; table.find('tr').eq(r).nextUntil(endRow).each(function () { let next = $(this).find('td').eq(col); let nextFirstColumnCell = next.siblings().eq(0); if (col === 0) { if (currentCell.text() === next.text()) { rowspan++; next.remove(); } } else { if (currentCell.text() === next.text() && firstColumnCell.text() === nextFirstColumnCell.text()) { rowspan++; next.remove(); } } }); currentCell.attr('rowspan', rowspan); } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant