🎨 Database table view supports paged loading https://github.com/siyuan-note/siyuan/issues/9424

This commit is contained in:
Daniel 2023-12-08 22:17:50 +08:00
parent 740422ba14
commit 9b28daf89d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -378,6 +378,27 @@ func renderAttributeView(attrView *av.AttributeView, viewID string, page, pageSi
viewable.FilterRows()
viewable.SortRows()
viewable.CalcCols()
// 分页
switch viewable.GetType() {
case av.LayoutTypeTable:
table := viewable.(*av.Table)
table.RowCount = len(table.Rows)
if 1 > view.Table.PageSize {
view.Table.PageSize = 50
}
table.PageSize = view.Table.PageSize
if 1 > pageSize {
pageSize = table.PageSize
}
start := (page - 1) * pageSize
end := start + pageSize
if len(table.Rows) < end {
end = len(table.Rows)
}
table.Rows = table.Rows[start:end]
}
return
}
@ -621,24 +642,6 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View, page, p
}
return iv < jv
})
// 分页
ret.RowCount = len(ret.Rows)
if 1 > view.Table.PageSize {
view.Table.PageSize = 50
}
ret.PageSize = view.Table.PageSize
if 1 > pageSize {
pageSize = ret.PageSize
}
start := (page - 1) * pageSize
end := start + pageSize
if len(ret.Rows) < end {
end = len(ret.Rows)
}
ret.Rows = ret.Rows[start:end]
return
}