bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.
https://pluto.weblaze.dev
MIT License
637 stars 291 forks source link

[Feature] auto fit? #920

Closed lublak closed 7 months ago

lublak commented 10 months ago

Currently i use PlutoInfinityScrollRows. But currently most columns are to big and not fit. I also tried all combinations of:

autoSizeMode: PlutoAutoSizeMode.scale,
resizeMode: PlutoResizeMode.none,

I also tried to trigger the autofit method:

onLoaded: (PlutoGridOnLoadedEvent event) {
  stateManager = event.stateManager;
  stateManager.setShowColumnFilter(true);
  stateManager.setSelectingMode(PlutoGridSelectingMode.row);
  stateManager.addListener(() {
    for (var col in stateManager.columns) {
      stateManager.autoFitColumn(
        stateManager.gridKey.currentContext!,
        col,
      );
    }
  });
},

But the colums not auto resize. grafik

lublak commented 10 months ago

The issue is the resize mode:

configuration: const PlutoGridConfiguration(
  columnSize: PlutoGridColumnSizeConfig(
    resizeMode: PlutoResizeMode.none,
  ),
),

you need to enable resize before autofit the columns:

stateManager.addListener(() {
  stateManager.setColumnSizeConfig(
    const PlutoGridColumnSizeConfig(
      resizeMode: PlutoResizeMode.normal,
    ),
  );
  for (var col in stateManager.columns) {
    stateManager.autoFitColumn(
      stateManager.gridKey.currentContext!,
      col,
    );
  }
  stateManager.setColumnSizeConfig(
    const PlutoGridColumnSizeConfig(
      resizeMode: PlutoResizeMode.none,
    ),
  );
});
github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 30 days with no activity.

TienLen2808 commented 9 months ago

onLoaded: (PlutoGridOnLoadedEvent event) { for(int i = 0 ;i < (columns.length - 3); i++) { event.stateManager.autoFitColumn(context, columns[i+3]); } },

i am used auto fix autoFitColumn !!

TienLen2808 commented 9 months ago

use index of column , to know which columns need to be auto-fixed

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 7 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.