用dataview查询客户汇总表,由于客户数量会与日俱增,到时会显示很长一串,影响阅读。查询结果显示的仅有客户名称一栏,所以希望能分栏显示,比如分3-4栏显示,这个栏的高度会随着数量的增加而增长。同时希望,点击客户名称能跳转到相应的客户名称的总览表上。
用deepseek试过dataviewjs,采用html方式分栏等等,要么能分栏,但不能点击跳转,要么就假分栏,还是竖向排列。最后它让我手动输入写死算了。![]()
不知各位大佬,有没有什么好办法。
const customers = dv.pages('"10_Projects"')
.where(p => p.customer != null && p.project != null)
.groupBy(p => p.customer)
.key
.sort();
const total = customers.length;
// ========================================
// 智能计算列数
// ========================================
let columns = 2;
if (total > 10) columns = 3;
if (total > 20) columns = 4;
if (total > 35) columns = 5;
const perColumn = Math.ceil(total / columns);
// ========================================
// 按列分组数据
// ========================================
const columnData = [];
for (let j = 0; j < columns; j++) {
const col = [];
for (let i = 0; i < perColumn; i++) {
const idx = i + j * perColumn;
if (idx < total) {
const c = customers[idx];
col.push('[[' + c + '/' + c + '|' + c + ']]');
}
}
columnData.push(col);
}
// ========================================
// 用 HTML 表格实现分栏
// ========================================
let html = '<div style="margin-top: 8px;">';
html += '<table style="width: 100%; border-collapse: collapse;">';
html += '<tr>';
for (let j = 0; j < columns; j++) {
const col = columnData[j];
html += '<td style="vertical-align: top; padding: 4px 20px 4px 0; border: none; width: ' + (100/columns) + '%;">';
html += '<ul style="list-style: none; padding-left: 0; margin: 0;">';
for (const item of col) {
html += '<li style="padding: 3px 0;">• ' + item + '</li>';
}
html += '</ul>';
html += '</td>';
}
html += '</tr>';
html += '</table>';
html += '</div>';
dv.paragraph("📊 共 **" + total + "** 个客户,分 **" + columns + "** 栏显示");
dv.span(html);