shadcn_ui-table
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShadcn UI — Table
Shadcn UI — 表格
Instructions
使用说明
ShadTableShadTable.listheaderfooterShadTableCell.headerShadTableCell.footerchildrenShadTableCellShadTablecolumnCountrowCountheaderbuilderfootercolumnSpanExtentFixedTableSpanExtent(130)MaxTableSpanExtent(FixedTableSpanExtent(120), RemainingTableSpanExtent())ShadTableShadTable.listheaderfooterShadTableCell.headerShadTableCell.footerchildrenShadTableCellcolumnCountrowCountheaderbuilderfooterShadTablecolumnSpanExtentFixedTableSpanExtent(130)MaxTableSpanExtent(FixedTableSpanExtent(120), RemainingTableSpanExtent())List (small tables)
列表模式(小型表格)
dart
ShadTable.list(
header: const [
ShadTableCell.header(child: Text('Invoice')),
ShadTableCell.header(child: Text('Status')),
ShadTableCell.header(child: Text('Method')),
ShadTableCell.header(
alignment: Alignment.centerRight,
child: Text('Amount'),
),
],
footer: const [
ShadTableCell.footer(child: Text('Total')),
ShadTableCell.footer(child: Text('')),
ShadTableCell.footer(child: Text('')),
ShadTableCell.footer(
alignment: Alignment.centerRight,
child: Text(r'$2500.00'),
),
],
columnSpanExtent: (index) {
if (index == 2) return const FixedTableSpanExtent(130);
if (index == 3) {
return const MaxTableSpanExtent(
FixedTableSpanExtent(120),
RemainingTableSpanExtent(),
);
}
return null;
},
children: invoices.map(
(invoice) => [
ShadTableCell(
child: Text(
invoice.invoice,
style: const TextStyle(fontWeight: FontWeight.w500),
),
),
ShadTableCell(child: Text(invoice.paymentStatus)),
ShadTableCell(child: Text(invoice.paymentMethod)),
ShadTableCell(
alignment: Alignment.centerRight,
child: Text(invoice.totalAmount),
),
],
),
)dart
ShadTable.list(
header: const [
ShadTableCell.header(child: Text('Invoice')),
ShadTableCell.header(child: Text('Status')),
ShadTableCell.header(child: Text('Method')),
ShadTableCell.header(
alignment: Alignment.centerRight,
child: Text('Amount'),
),
],
footer: const [
ShadTableCell.footer(child: Text('Total')),
ShadTableCell.footer(child: Text('')),
ShadTableCell.footer(child: Text('')),
ShadTableCell.footer(
alignment: Alignment.centerRight,
child: Text(r'$2500.00'),
),
],
columnSpanExtent: (index) {
if (index == 2) return const FixedTableSpanExtent(130);
if (index == 3) {
return const MaxTableSpanExtent(
FixedTableSpanExtent(120),
RemainingTableSpanExtent(),
);
}
return null;
},
children: invoices.map(
(invoice) => [
ShadTableCell(
child: Text(
invoice.invoice,
style: const TextStyle(fontWeight: FontWeight.w500),
),
),
ShadTableCell(child: Text(invoice.paymentStatus)),
ShadTableCell(child: Text(invoice.paymentMethod)),
ShadTableCell(
alignment: Alignment.centerRight,
child: Text(invoice.totalAmount),
),
],
),
)Builder (large tables)
构建器模式(大型表格)
Use . The builder receives a table index with and . Prefer builder for large data so only visible rows are built.
ShadTable(columnCount:, rowCount:, header: (context, column) => ..., columnSpanExtent: (index) => ..., builder: (context, index) => ShadTableCell(...), footer: (context, column) => ...)rowcolumn使用。构建器会接收包含和的表格索引。对于大数据量,建议使用构建器模式,这样只会构建可见的行。
ShadTable(columnCount:, rowCount:, header: (context, column) => ..., columnSpanExtent: (index) => ..., builder: (context, index) => ShadTableCell(...), footer: (context, column) => ...)rowcolumnAdditional resources
额外资源
Detailed column span and builder patterns: reference.md.
关于列跨度和构建器模式的详细说明:reference.md。