iter(g88): 数据表支持导出 CSV
This commit is contained in:
@@ -154,4 +154,22 @@ assert(
|
||||
'reset 回到默认态(排序/筛选清空,分页回 1/20)',
|
||||
);
|
||||
|
||||
// getAllRows:过筛选 + 排序但跳过分页,供导出用
|
||||
const all = createTable({
|
||||
data: users,
|
||||
columns: [{ key: 'name', header: 'Name' }, { key: 'city', header: 'City' }],
|
||||
rowKey: 'id',
|
||||
plugins: [filterPlugin(), sortPlugin(), paginationPlugin()],
|
||||
initialState: { pagination: { page: 1, pageSize: 2 } },
|
||||
});
|
||||
assert(all.getVisibleRows().rows.length === 2, 'getVisibleRows 受分页约束只给当页');
|
||||
all.dispatch({ type: 'setFilter', key: 'city', value: 'Beijing' });
|
||||
assert(all.getAllRows().rows.length === 2 && all.getVisibleRows().rows.length === 2, 'getAllRows 跳过分页但与筛选一致(Beijing 2 行)');
|
||||
all.dispatch({ type: 'toggleSort', key: 'age' });
|
||||
assert(
|
||||
JSON.stringify(all.getAllRows().rows.map((r) => r.id)) === JSON.stringify([4, 2]),
|
||||
'getAllRows 仍按排序规则排(age 升序 4→2)',
|
||||
);
|
||||
assert(all.getPageInfo().totalPages === 1, 'getAllRows 不影响分页快照(2 行 / 每页 2 = 1 页)');
|
||||
|
||||
console.log('SMOKE OK');
|
||||
|
||||
Reference in New Issue
Block a user