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

DataGrid: Group header column width fix #5815

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,7 @@ internal IEnumerable<DataGridColumn<TItem>> DisplayableColumns
for ( int i = 0; i < orderedDisplayColumns.Count; i++ )
{
var displayColumn = orderedDisplayColumns[i];
displayColumn.SetWidthToNull();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should modify the Width here. What will happen when the user-defined the width on their side?

I think we should just change the Bootstrap CSS when the grouping is enabled on a table.

Here is an example from my comment in the ticket, as a reference:

.table-fixed-header table.b-table
{
  width: unset:
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"What will happen when the user-defined the width on their side?" -> that's exactly what the bug is about. When user defines width it inherits after the first column that was defined with HeaderGroupCaption. Now it tries to squeeze 3 (or what ever count) columns into the size of 1...
With width disabled on header group, users can still set the width by defining it by the width of the individual items (which is exactly what is done in the bug report).

The css fix messes up the layout on bigger screens for example (isn't stretching itself to 100%)

Copy link
Contributor

@David-Moreira David-Moreira Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"What will happen when the user-defined the width on their side?" -> that's exactly what the bug is about. When user defines width it inherits after the first column that was defined with HeaderGroupCaption. Now it tries to squeeze 3 (or what ever count) columns into the size of 1...

I think @stsrki meant the user defining the width in a CSS file meaning that your solution would only fix by overriding any Width explicitly defined as a Parameter and not as a css defined rule targeting that column, is this not the case?

So if @stsrki solution with css also fixes the issue in the same way yours do. Then his solution has the advantage to also work over user's defined css. I'd personally take that approach if it works with no other issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, I'd make it clear somewhere that this feature does not work properly with explicitly defined widths and make sure that the user knows what will happen.
Somethign along this lines:

  • By enabling HeaderGroupCaption any explicitly defined width will be ignored, etc....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to do it by style - because user has dedicated Width property for that.

I agree, In my onion, never ever assume what the user should do. There might be a myriad of reasons why he would set the width through regular styling... and it's perfectly reasonable to do so by styling.
So unless we deem something as unsuported by the framework/product we're providing, then if it's available the user might use it and we might want to handle it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, right..

So we have two solutions, both with breaking change.

What about letting users to do their own styling on the header group cell?

something like:

<DataGridColumn Classes="what ever now user is responsible" IsHeaderGroup HeaderGroupCaption="Personal Info">
    
</DataGridColumn>

And instead of taking the styling from the first DataGridColumn with HeaderGroupCaption="Personal Info", it would just take the one with IsHeaderGroup. This might actually simplify few things along the line.
Not a quick fix, but imo the cleanest solution...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can already assign the class via the styling and cell styling callbacks on a column. And there is also a Class on a DataGrid.

I think it is best if we postpone this until we figure the best way of handling it. The problem is more in how the CSS is done on the bootstrap side. And user has a workaround by adding a bit of custom CSS if neeeded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, just to be clear, this PR is postponed then? Should it be left hanging? OR should we update the issue with our findings and reject it for the time being?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is postponed. I will update the issue.

var colSpan = 1;

if ( !string.IsNullOrWhiteSpace( displayColumn.HeaderGroupCaption ) && orderedDisplayColumns.Count > i + 1 )
Expand Down
2 changes: 2 additions & 0 deletions Source/Extensions/Blazorise.DataGrid/DataGridColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ internal DataGridColumnFilterMethod GetDataGridFilterMethodAsColumn()
: ParentDataGrid.FilterMethod == DataGridFilterMethod.NotEquals ? DataGridColumnFilterMethod.NotEquals
: DataGridColumnFilterMethod.Contains;
}

internal void SetWidthToNull()=> Width = null;//to supress BL0005

#endregion

Expand Down
Loading