【发布时间】:2021-04-16 20:52:18
【问题描述】:
如何使用内置函数对DataTable 上的列进行排序。
是否可以对多个列进行操作,这样当我按下排序图标时,它实际上会对列表进行排序?
感谢您的支持:)
class HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
var myColumns = [
new DataColumn(label: new Text('name')),
new DataColumn(label: new Text('age')),
new DataColumn(label: new Text('Hight')),
];
var myRows = [
new DataRow(cells: [
new DataCell(new Text('George')),
new DataCell(new Text('18')),
new DataCell(new Text('173cm')),
]),
new DataRow(cells: [
new DataCell(new Text('Dave')),
new DataCell(new Text('21')),
new DataCell(new Text('183cm')),
]),
new DataRow(cells: [
new DataCell(new Text('Sam')),
new DataCell(new Text('55')),
new DataCell(new Text('170cm')),
])
];
return new Scaffold(
body: new Center(
child: new Container(
child: new DataTable(
columns: myColumns,
rows: myRows,
sortColumnIndex: 0,
sortAscending: true,
)),
),
);
}
}
【问题讨论】:
标签: flutter