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

Fix default expanded row keys #497

Merged
merged 5 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/drip-table/props/current-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const schema = {
},
},
],
pagination: {
pageSize: 20,
},
};

const dataSource = [
Expand Down
16 changes: 8 additions & 8 deletions docs/drip-table/props/default-expanded-row-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,22 @@ const dataSource = [
subtable: [
{
id: '1-1',
name: '苹果',
name: '苹果A',
description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '1-1-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '1-1-1', name: '苹果A1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
{
id: '1-2',
name: '',
name: '梨A',
description: '通常是一种落叶乔木或灌木,极少数品种为常绿,属于蔷薇目蔷薇科苹果族',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '1-2-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '1-2-1', name: '梨A1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
],
Expand All @@ -151,22 +151,22 @@ const dataSource = [
subtable: [
{
id: '2-1',
name: '苹果',
name: '苹果B',
description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '2-1-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '2-1-1', name: '苹果B1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
{
id: '2-2',
name: '',
name: '梨B',
description: '通常是一种落叶乔木或灌木,极少数品种为常绿,属于蔷薇目蔷薇科苹果族',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '2-2-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '2-2-1', name: '梨B1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
],
Expand Down
16 changes: 8 additions & 8 deletions docs/drip-table/props/subtable-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,22 @@ const dataSource = [
subtable: [
{
id: '1-1',
name: '苹果',
name: '苹果A',
description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '1-1-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '1-1-1', name: '苹果A1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
{
id: '1-2',
name: '',
name: '梨A',
description: '通常是一种落叶乔木或灌木,极少数品种为常绿,属于蔷薇目蔷薇科苹果族',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '1-2-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '1-2-1', name: '梨A1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
],
Expand All @@ -184,22 +184,22 @@ const dataSource = [
subtable: [
{
id: '2-1',
name: '苹果',
name: '苹果B',
description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '2-1-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '2-1-1', name: '苹果B1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
{
id: '2-2',
name: '',
name: '梨B',
description: '通常是一种落叶乔木或灌木,极少数品种为常绿,属于蔷薇目蔷薇科苹果族',
status: 'onSale',
price: 799,
subtableLevel2: [
{ id: '2-2-1', name: '苹果', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
{ id: '2-2-1', name: '梨B1', description: '是苹果树的果实,一般呈紅色,但需視品種而定,富含矿物质和维生素', status: 'onSale', price: 799 },
],
},
],
Expand Down
3 changes: 3 additions & 0 deletions docs/drip-table/props/total.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const schema = {
},
},
],
pagination: {
pageSize: 20,
},
};

const dataSource = [
Expand Down
2 changes: 1 addition & 1 deletion packages/drip-table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drip-table",
"version": "3.2.1-alpha.10",
"version": "3.2.1-alpha.12",
"description": "A tiny and powerful enterprise-class solution for building tables.",
"main": "dist/index.min.js",
"module": "lib/index.js",
Expand Down
9 changes: 8 additions & 1 deletion packages/drip-table/src/layouts/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,9 @@ function TableLayout<
const subtable = tableProps.schema.subtable;
const rowExpandable = tableProps.rowExpandable;
if (rowExpandColumnVisible) {
const defaultExpandedRowKeys = rowKey && Array.isArray(tableProps.defaultExpandedRowKeys)
? tableProps.defaultExpandedRowKeys?.map(k => rcTableDataSource.find(v => v.record[rowKey] === k)?.key).filter(Boolean)
: void 0;
return {
expandIcon: RcExpandIcon,
expandedRowRender: RcExpandRowRender,
Expand All @@ -1871,14 +1874,18 @@ function TableLayout<
return false;
},
defaultExpandAllRows: tableProps.defaultExpandAllRows,
defaultExpandedRowKeys: tableProps.defaultExpandedRowKeys,
defaultExpandedRowKeys: defaultExpandedRowKeys as typeof tableProps.defaultExpandedRowKeys,
};
}
return void 0;
},
[
tableProps.schema.subtable,
tableProps.rowExpandable,
tableProps.defaultExpandAllRows,
tableProps.defaultExpandedRowKeys,
rowKey,
rcTableDataSource,
RcExpandIcon,
RcExpandRowRender,
],
Expand Down
Loading