doonfrs / pluto_grid_plus

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
27 stars 28 forks source link

[Bug] First column doesn't freeze when programatically yet reported as it has via manual clicks on header #3

Open mrgithub opened 10 months ago

mrgithub commented 10 months ago

When I freeze the first column it is not visually frozen but the menu bar says it is when clicked. State manager says it's not frozen. No frozen columns are bigger than 200. I don't understand why it doesn't work.

First column looks like this:

 List<PlutoColumn> get columns {
    return <PlutoColumn>[
      PlutoColumn(
        title: 'Date',
        field: 'date',
        type: PlutoColumnType.date(format: "dd MMM"),
        readOnly: true,
        backgroundColor: Colors.black,
        enableColumnDrag: false,
        enableRowDrag: false,
        enableSorting: false,
        frozen: PlutoColumnFrozen.start,   // this should freeze it and should be enough
        titleSpan: getTitleSpan('Date'),
      ),

onLoaded looks like this:

onLoaded: (PlutoGridOnLoadedEvent event) {
                event.stateManager.setShowColumnFilter(false);
                event.stateManager.setColumnSizeConfig(
                    PlutoGridColumnSizeConfig(
                        autoSizeMode: PlutoAutoSizeMode.scale));
                event.stateManager.columns[0].frozen = PlutoColumnFrozen.start;   // tried to freeze it again just in case
                print("***frozen " + event.stateManager.showFrozenColumn.toString());  // shows false
              },
RADeveloping commented 9 months ago

I think it's calculating the width of all the starting frozen columns. I'm assuming you have more than one frozen column. To test you can unfreeze your other columns and only have your first column frozen.

 @override
  double get leftFrozenColumnsWidth {
    double width = 0;

    for (final column in refColumns) {
      if (column.frozen.isStart) {
        width += column.width;
      }
    }

    return width;
  }
doonfrs commented 9 months ago

Width calculation is sensitive, I don't think I will have time for it soon, but if someone creates a PR I will review & locally test it.