We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to change the orientation of the header text of column?

Here are screenshots

Attachment: Archive_5e5cf919.zip

3 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team August 2, 2019 06:09 AM

Hi Hassan Tariq, 
 
Thank you for contacting Syncfusion support. 
 
We don’t have direct support for your requirement of changing orientation of DataGrid Header Text and it can be achieved using “HeaderTemplate” support in each DataColumn in SfDataGrid. By defining the label as the header template as a DataTemplate and set the rotation property value “-90” or “90” to make a rotation. You can change the rotation value based on your requirement. However we need to manual define the header row height to avoid text clipping in view, because we didn’t have the support for “DataTemplate” auto sizing the height. 
  
Please refer the following code snippet, 
  
[Xaml 
  
<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> 
             
 
We have attached the sample
for your reference, 
 
  
 
  
We hope that this helps, please let us know if you would require any assistance. 
 
Regards,
Subburaj Pandian V  



ED Eddy November 11, 2020 10:37 AM

Is there a way to control the width of the columns? The column's width seems to match the label width as if it wasn't rotated. I tried setting ColumnSizer="None" but then my label text gets wrapped to a second and 3rd line if they're too long. If I set LineBreakMode="NoWrap" then the text gets truncated. This is what I'm trying to achieve:




KK Karthikraja Kalaimani Syncfusion Team November 12, 2020 07:40 AM

 
Hi Eddy,

Please set the columnsizer as Auto, so it will set the column width based on content width. Please refer the below UG document.

https://help.syncfusion.com/xamarin/datagrid/column-sizer#columnsizerauto


Regards,
Karthik Raja
 


Loader.
Live Chat Icon For mobile
Up arrow icon