【问题标题】:How to hide DataTable's column header in Flutter?如何在 Flutter 中隐藏 DataTable 的列标题?
【发布时间】:2020-06-20 14:30:17
【问题描述】:

如何在 Flutter 中隐藏 DataTable 的列标题?
DataTable in Flutter

DataTable(
  headingRowHeight: 0,
  columns: <DataColumn>[
  DataColumn(label: Text("Name")),
  DataColumn(label: Text("Hour")),
  DataColumn(label: Text("Tag")),
  DataColumn(label: Text("Date")),
  DataColumn(label: Text("Action")),

], rows: lstCourse.map((e) => DataRow(
  cells: <DataCell>[
    DataCell(Text(e.Name)),
    DataCell(Text(e.Hour_Text)),
    DataCell(Text(e.Tag)),
    DataCell(Text(e.StartDate_Text)),
    DataCell(RaisedButton(onPressed: (){}, child: Text("Đăng ký"),)),
  ]
)).toList()
);

我试图在 DataTable 类中找到一些选项,但似乎不存在

【问题讨论】:

  • 设置headingRowHeight = 0.0 ?
  • @Kahou 设置 headerRowHeight 不起作用
  • 您能否编辑您的问题以添加相关的 html 和代码(作为文本,而不是链接)?可能有多种可能的解决方案,但这取决于您的表是如何定义的。
  • @andrewjames 已经更新
  • 你能显示表格的 html 定义吗?或者显示 HTML 是如何生成的?

标签: flutter dart mobile datatable


【解决方案1】:

headingRowHeight 为 0,空容器为 DataColumn 标签

DataTable(
         headingRowHeight: 0,
         columns: [
           DataColumn(label: Container()),
           DataColumn(label: Container()),
           DataColumn(label: Container()),
           DataColumn(label: Container()),
           DataColumn(label: Container()),
         ],
         rows: ..
    ),

【讨论】:

  • 第一个分隔线仍然存在,所以我还使用dividerThickness: double.minPositive 来摆脱所有分隔线。我不知道如何只去掉第一个分隔符。
【解决方案2】:

将headingRowHeight设置为0,所有标签文本为空字符串DataColumn(label: Text(""))

【讨论】:

    猜你喜欢
    • 2015-07-12
    • 1970-01-01
    • 2022-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-17
    • 2023-02-17
    • 2020-02-17
    相关资源
    最近更新 更多