<dataGrid:SfDataGrid HeaderRowHeight="100">
<dataGrid:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns">
<dataGrid:GridTextColumn
MappingName="OrderID"
Padding="0,0,0,0">
<dataGrid:GridTextColumn.HeaderTemplate>
<DataTemplate>
<Label Text="OrderID"
HorizontalOptions="Center"
VerticalOptions="Center"
Rotation="90"
LineBreakMode="WordWrap"
TextColor="Black"/>
</DataTemplate>
</dataGrid:GridTextColumn.HeaderTemplate>
</dataGrid:GridTextColumn>
</dataGrid:SfDataGrid.Columns>
</dataGrid:SfDataGrid>
|
|
I would like to join here. I can't get the width of the column to display correctly either.
My headings are mostly 2 lines. This makes it necessary to set the label to MaxLines = 2 and NoWrap.
But the width of the column always looks way too wide as soon as it is 2 line headings.
One line in the label takes about 48px and then the column takes about 122px. That would be nice if the width of the column was already narrower.
But with 2 line labels (96px) the column becomes about 238px wide.
I have also attached my extended test project, in which our requirements are shown approximately. If I create a CustomColumnSizer, then the text in the labels is cut off again.
Attachment: SupportXForms_37a0e629.zip
Hi Björn Möller,
We have analyzed your query. We would like to let you know that, In sfdatagrid, when using ColumnSizer.Auto, it means that the width of a column will be determined by the cell containing the longest sentence or word. In your specific case, if the second line of the heading label has a longer sentence, the width of the respective column will be adjusted accordingly based on that length. This behavior remains consistent even if you rotate the header content (Label).
If you manually modify the rotated height to become the width of a particular column, it will impact the content height (Label) and adjust it to the entered width. This behavior is inherent to the default functionality of SfDataGrid.
To illustrate, consider a Label with a height of 50 and width of 100. When rotated to 90 or -90 degrees and you manually set the column width to 50 after rotation, the label's dimensions adjust as follows: the width becomes 50 and the height becomes 100 in 90-degree rotation. In your sample, if you set MaxLines to a value between 5 - 7, you will be able to view the remaining text, but this adjustment won't impact the column width. Please refer the below screenshot for more details.
Regards,
Diwakar V
Hello Diwakar,
thank you for the detailed answer. I encountered exactly this problem and could not solve it. Either the label was too small after rotation, or the column was too large. There doesn't seem to be an acceptable solution for this.
I have now worked around it by building my own "Label" control from an SKCanvasView. Then the column width is fixed and I just draw the text with the -90 degree rotation.
Cumbersome, but works. Thanks for the help though.
Many greetings from Cologne,
Björn
Björn
Glad that your issue is resolved!! Please let us know if you have any further queries on this. We are happy to help.