Skip to content

fix: Dynamic columns does not update grid-template-columns #3332

@davhdavh

Description

@davhdavh

🐛 Bug Report

The grid does not recognize that the list of columns has changed and thus does not reevaluate the width calculation

💻 Repro or Code Sample

https://www.fluentui-blazor.net/#dynamiccolumns click any of the column button, see that tables style is static at grid-template-columns: 100px 200px;

🤔 Expected Behavior

when all 3 cols are shown, it updates to grid-template-columns: 100px 200px 200px; to match the column widths

😯 Current Behavior

Nothing happens on click

💁 Possible Solution

Hacked workaround:

<FluentDataGrid @ref="Grid" ... GridTemplateColumns="@HackColumnWidthBroken">
...
@code {
   private async Task OpenChooseColumnsDialog()
   {
      var dialog = await DialogService.Show(DialogHelper.From<MyColumnSelector>(), State, parameters);
      var res    = await dialog.Result;
      if (!res.Cancelled)
      {
         HackColumnWidthBroken +=  " ";
         await Grid.RefreshDataAsync();
      }
   }
}

this is working because Grid.OnParametersSetAsync only checks for null on GridTemplateColumns, but FinishCollectingColumns use string.IsNullOrWhiteSpace(GridTemplateColumns), which in itself is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew issue. Needs to be looked at

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions