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

igx-grid: Cannot set grouped column width in percentage. #4155

Closed
mkamiishi opened this issue Mar 4, 2019 · 7 comments
Closed

igx-grid: Cannot set grouped column width in percentage. #4155

mkamiishi opened this issue Mar 4, 2019 · 7 comments

Comments

@mkamiishi
Copy link

Description

Cannot set grouped column width in percentage.

  • igniteui-angular version: 7.1.9, 7.2.0-rc.1
  • browser: Chrome

Steps to reproduce

Run the attached sample.

Result

Column width is not correct for col2 and col3.

Expected result

Column width should reflect the values set in width property.

Attachments

igxGrid.zip

@ddincheva
Copy link
Contributor

Hello @mkamiishi ,
I have downloaded and run the attached sample, but I can not see a problem in this sample. The grid is rendered as expected and the columns are calculated correctly: When we have column groups and for specific column group there is not defined width, the width is calculated as a sum of its children width; and for each child column the width is calculated based on the size of its parent. So in the sample that you have attached col2 is 20% of the width of group1 and group1 is 40% of the width of grid component.
image
So what is the behavior that you expect?! Can you, please, describe in more details?

@mkamiishi
Copy link
Author

Hi @ddincheva,

I now understand that widths of child headers are calculated based on the parent header width.

The header layout I was looking for with the attached sample is this:
"col1" - 20%, "col2" - 20%, "col3" - 20%, and "col4" - 40% - of the grid total width, where col2 and col3 are grouped into "group1" whose width is 40%(20% + 20%) of the grid total width.

I changed the html like below, but now the grid shows a horizontal scrollbar.

<igx-grid [data]="datasource" [autoGenerate]="false" [width]="'600px'" [height]="'300px'">
<igx-column field="col1" header="col1" [width]="'20%'">
<igx-column-group header="group1" [width]="'40%'">
<igx-column field="col2" header="col2" [width]="'50%'">
<igx-column field="col3" header="col3" [width]="'50%'">

<igx-column field="col4" header="col4" [width]="'40%'">

I would like the sum of all the column headers to be 100% of the grid width. How am I supposed to define a grid like this?

@ddincheva
Copy link
Contributor

Hello @mkamiishi ,
I investigated the matter a little more deeper and currently the behavior that you want to achieve is not possible, because igx-grid provides a limited support when set the column width in percents. At the moment the predefined behavior defining the column width is the following: you can not set directly a width to a group column nor in pixels neither in percents, because in this way we prevent the case when the parent column width is not enough to fit all of its child columns. But any way, I consider your scenario for an absolutely valid and I think it is good to provide the described behavior when you set all of your column widths either in pixels and in percents and not mixing them. So I will change the label for this issue to a feature request and we will discuss and resolve this matter as soon as possible.

@ddincheva ddincheva added 🧰 feature-request 🆕 status: new and removed 🐛 bug Any issue that describes a bug 🧨 severity: medium 🛠️ status: in-development Issues and PRs with active development on them labels Mar 7, 2019
@zdrawku
Copy link
Contributor

zdrawku commented Nov 26, 2019

I wanted to provide a brief update of this requirement based on the discussion that we had with @radomirchev and @rkaraivanov. There are scenarios when having both parent and child columns set in % will cause inconsistencies and we cannot guarantee that the result will be what's expected by the end-user. We could consider the following behavior though, each child column to have its size calculated relatively to the Grid size, not based on the parent header width. Any other solution may affect the rendering performance of the grid and every resize interaction later on.

@github-actions
Copy link

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label Jun 27, 2020
@ddincheva ddincheva removed the status: inactive Used to stale issues and pull requests label Jun 29, 2020
@radomirchev radomirchev added the 🛠️ status: in-development Issues and PRs with active development on them label Aug 27, 2020
@ddincheva ddincheva removed the 🛠️ status: in-development Issues and PRs with active development on them label Sep 2, 2020
@ddincheva
Copy link
Contributor

ddincheva commented Sep 2, 2020

After resolving the following issue #5486 , the igxGrid now support setting column widths in both pixels and percentage.
Now when the width of a certain column is set in percentage, its width is calculated based on the grid width no matter if it is a regular column or is a child column part of column group hierarchy. The group column width can be set neither in pixels nor in percentage. Its width is always calculated as a sum of the widths of its children.
So if we want to achieve the layour described in the comment above we need to set the following values for the column widths:

<igx-grid [data]="datasource" [autoGenerate]="false" [width]="'600px'" [height]="'300px'">
<igx-column field="col1" header="col1" [width]="'20%'">
<igx-column-group header="group1">
<igx-column field="col2" header="col2" [width]="'20%'">
<igx-column field="col3" header="col3" [width]="'20%'">
</igx-column-group
<igx-column field="col4" header="col4" [width]="'40%'">

And this is the result:
20-20

@zdrawku
Copy link
Contributor

zdrawku commented Sep 4, 2020

Thank you @ddincheva for the thorough research and explanation. This decision is based on the discussions that we had with @radomirchev and @rkaraivanov. @mkamiishi if you have any questions or concerns do let us know.

@zdrawku zdrawku closed this as completed Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants