pluto_grid
pluto_grid copied to clipboard
[Feature] Strict column width
I am currently facing an issue with the rendered cells, because even though I set a specific width, the table scales its column width as it pleases. So, I think it would be nice to have a boolean property on column called "strictWidth" or something like that, that it works respecting the given width, regardless of the type of autofit the table has.
Thank you for reading.
I will consider adding this in the next version. thank you
Hey @bosskmk, Min width is also not respected by column ``autoSizeMode: PlutoAutoSizeMode.scale,``` could that be fixed without the need for this boolean?
Alternatively autoSizeMode: PlutoAutoSizeMode.scale, could take into account column heading width to set its size, right now it just truncades the title
@ted-marozzi It should be further developed. It currently refers to the default minWidth , not the setting in PlutoColumn.minWidth.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
until appearing next version you can try this:
final columns = state!.columns;
for (var element in columns) {
state!.resizeColumn(element, 0.1);
state!.resizeColumn(element, -0.1);
}
state!.notifyResizingListeners();
}
Fixed in PlutoGrid 5.4.8 version.
- Modified so that each
PlutoColumn.minWidth
is applied. - When
PlutoColumn.suppressedAutoSize
is set to true, it is modified to be ignored in auto size.
As in the example code below, set the width
of the column proportionally
If you set autoSizeMode
to PlutoAutoSizeMode.scale
you can get the flex effect.
Columns with width
set to 100, 200
are set to flex size in a ratio of 1:2
.
Columns for which suppressedAutoSize
is true
are ignored in auto size setting and fixed to the set width
.
import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';
import '../dummy_data/development.dart';
class EmptyScreen extends StatefulWidget {
static const routeName = 'empty';
const EmptyScreen({Key? key}) : super(key: key);
@override
_EmptyScreenState createState() => _EmptyScreenState();
}
class _EmptyScreenState extends State<EmptyScreen> {
late List<PlutoColumn> columns;
late List<PlutoRow> rows;
late PlutoGridStateManager stateManager;
@override
void initState() {
super.initState();
columns = [
PlutoColumn(
title: 'column1',
field: 'column1',
type: PlutoColumnType.text(),
width: 100,
),
PlutoColumn(
title: 'column2',
field: 'column2',
type: PlutoColumnType.text(),
suppressedAutoSize: true,
width: 150,
),
PlutoColumn(
title: 'column3',
field: 'column3',
type: PlutoColumnType.text(),
width: 200,
),
];
rows = DummyData.rowsByColumns(length: 10, columns: columns);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
padding: const EdgeInsets.all(15),
child: PlutoGrid(
columns: columns,
rows: rows,
onChanged: (PlutoGridOnChangedEvent event) {
print(event);
},
onLoaded: (PlutoGridOnLoadedEvent event) {
stateManager = event.stateManager;
},
configuration: const PlutoGridConfiguration(
columnSize: PlutoGridColumnSizeConfig(
autoSizeMode: PlutoAutoSizeMode.scale,
),
),
),
),
),
);
}
}