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

[Table]: 自定义列返回当前行号 #457

Merged
merged 1 commit into from
Jan 20, 2025
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
10 changes: 4 additions & 6 deletions tdesign-component/example/lib/page/td_table_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,12 @@ class TDTablePage extends StatelessWidget {
TDTableCol(
title: '标题',
colKey: 'title4',
cellBuilder: (BuildContext context) {
cellBuilder: (BuildContext context, int index) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TDText(
'修改',
forceVerticalCenter: true,
style: TextStyle(
color: TDTheme.of(context).brandNormalColor,
fontSize: 14,
Expand All @@ -134,7 +133,6 @@ class TDTablePage extends StatelessWidget {
),
TDText(
'通过',
forceVerticalCenter: true,
style: TextStyle(
color: TDTheme.of(context).brandNormalColor,
fontSize: 14,
Expand All @@ -160,7 +158,7 @@ class TDTablePage extends StatelessWidget {
TDTableCol(
title: '标题',
colKey: 'title4',
cellBuilder: (BuildContext context) {
cellBuilder: (BuildContext context, int index) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand Down Expand Up @@ -199,7 +197,7 @@ class TDTablePage extends StatelessWidget {
title: '标题',
colKey: 'title4',
fixed: TDTableColFixed.right,
cellBuilder: (BuildContext context) {
cellBuilder: (BuildContext context, int index) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand Down Expand Up @@ -292,7 +290,7 @@ class TDTablePage extends StatelessWidget {
title: '标题',
colKey: 'title4',
fixed: TDTableColFixed.right,
cellBuilder: (BuildContext context) {
cellBuilder: (BuildContext context, int index) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand Down
4 changes: 2 additions & 2 deletions tdesign-component/lib/src/components/table/td_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TDTableCol {
bool? ellipsisTitle;

/// 自定义列
WidgetBuilder? cellBuilder;
IndexedWidgetBuilder? cellBuilder;

/// 列内容横向对齐方式
TDTableColAlign? align;
Expand Down Expand Up @@ -375,7 +375,7 @@ class TDTableState extends State<TDTable> {
}
// 自定义单元格内容
if (col.cellBuilder != null) {
return Builder(builder: col.cellBuilder!);
return Builder(builder: (_) => col.cellBuilder!(_, index));
}
return titleWidget;
}
Expand Down
Loading