Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the ability to specify a column width at the column level for the FluentDataGrid #1901

Closed
StevenRasmussen opened this issue Apr 19, 2024 · 5 comments
Labels
closed:done Work is finished improvement A non-feature-adding improvement
Milestone

Comments

@StevenRasmussen
Copy link
Contributor

🙋 Feature Request

It would be ideal to be able to specify the column width for a column at the column level instead of using the GridTemplateColumns property of the data grid. When building a dynamic grid that allows for adding/removing columns at runtime, and you have column widths specified using the GridTemplateColumns property, you must also somehow dynamically update that property to correctly reflect which columns are going to be rendered. Otherwise, the rendering of the columns gets out of whack.

🤔 Expected Behavior

Rendering of a data grid with dynamically added/removed columns should render correctly with column widths that are specified at design time.

😯 Current Behavior

If you add/remove columns from a data grid that has the GridTemplateColumns specified, you must also dynamically create that string value.

💁 Possible Solution

Add a new property at the column level called TemplateColumn or Width that the grid would use to dynamically set the GridTemplateColumns property.

@microsoft-github-policy-service microsoft-github-policy-service bot added the triage New issue. Needs to be looked at label Apr 19, 2024
@dvoituron
Copy link
Collaborator

This would be possible, but would conflict with the existing GridTemplateColumns property.
For example, how to handle a mix of Width properties with values already specified for GridTemplateColumns.
I think it would be more appropriate to consider this change in a future major update.

We need to think about a solution that doesn't involve Breaking Change.

@StevenRasmussen
Copy link
Contributor Author

I feel like you wouldn't want to mix/match specifying the width at the column level AND with the GridTemplateColumns. I feel like it should be one OR the other. If we assume that, then we could provide logic that would throw an error if they tried to specify it in both places. Thoughts?

@vnbaaij
Copy link
Collaborator

vnbaaij commented Apr 19, 2024

With the current rendering method (using the web components) we always need the GridTemplateColumn parameter.
That is why removing it would be a breaking change

@StevenRasmussen
Copy link
Contributor Author

Sorry... I haven't been very clear in what I was thinking with regards to the design around this. I'm not suggesting that we remove the GridTemplateColumns parameter. My suggestion is that we either:

  1. Use the user supplied GridTemplateColumns parameter and pass it to the underlying web component.
  2. OR dynamically generate a GridTemplateColumns parameter based on the individual values supplied by each column (or use a default of auto for any columns that do not have it specified) and pass that down to the web component.

Some pseudo code of the logic (I apologize for any incorrect syntax or spelling errors... just typing it out here):

if(!string.IsNullOrWhitespace(grid.GridTemplateColumns) && grid.Columns.Any(x => !string.IsNullOrWhitespace(x.Width))
{
    throw new Exception("You can only specify either the 'GridTemplateColumns' property on the grid, or the 'Width' property at the column level, not both.");
}

var gridTemplateColumnsToPassToWebComponent = grid.GridTemplateColumns;
if(string.IsNullOrWhitespace(gridTemplateColumnsToPassToComponent) && grid.Columns.Any(x => !string.IsNullOrWhitespace(x.Width))
{
    gridTemplateColumnsToPassToWebComponent = string.Join(" ", grid.Columns.Select(x => x.Width ?? "auto"));
}

// Pass the `gridTemplateColumnsToPassToWebComponent` down to the web component
...

Hopefully that makes sense. Doing it this way would not introduce a breaking change. Thoughts?

@dvoituron
Copy link
Collaborator

Yep. That could be a solution

@vnbaaij vnbaaij added improvement A non-feature-adding improvement status:in-progress Work is in progress and removed triage New issue. Needs to be looked at labels Apr 21, 2024
@vnbaaij vnbaaij modified the milestones: v4.6.2, v4.7.0 Apr 21, 2024
@vnbaaij vnbaaij added closed:done Work is finished and removed status:in-progress Work is in progress labels Apr 22, 2024
@vnbaaij vnbaaij closed this as completed Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:done Work is finished improvement A non-feature-adding improvement
Projects
None yet
Development

No branches or pull requests

3 participants