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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the sfdatagrid header text font style ?

Thread ID:

Created:

Updated:

Platform:

Replies:

128702 Feb 7,2017 12:47 AM UTC Feb 7,2017 02:10 PM UTC Xamarin.Forms 3
loading
Tags: SfDataGrid
K Guptha
Asked On February 7, 2017 12:47 AM UTC

is there any simple way to modify the Column header text value

if (e.Column.MappingName == "Dept")
{
e.Column.TextAlignment = TextAlignment.Center;
e.Column.HeaderText = "Developer consultant";
}
here I would like to change the header text font as bold, blue color for the first string (Developer) and Gray color for the second string (consultant). Can you please help me with this any sample or example. Is it possible to do with SfDataGrid ?

Divakar Subramaniam [Syncfusion]
Replied On February 7, 2017 07:19 AM UTC

Hi Kumar, 
 
 
If you need to change the HeaderText’s Font style, then it is possible by setting HeaderFontAttribute property as “Bold” or any other. Please refer the below code snippet. 
 
<sfGrid:GridTextColumn HeaderFontAttribute="Bold" MappingName="CustomerID" /> 
 
 
If you need to change the Font color, then it is not possible to achieve directly like above case. However, you can achieve it by using HeaderTemplate. Please refer the below code snippet. 
 
<sfGrid:GridTextColumn MappingName="CustomerID"> 
    <sfGrid:GridTextColumn.HeaderTemplate> 
          <DataTemplate> 
               <Label Text="CustomerID" TextColor="Blue" /> 
          </DataTemplate> 
    </sfGrid:GridTextColumn.HeaderTemplate> 
</sfGrid:GridTextColumn> 
 
 
We have prepared a simple sample for your reference and you can download the same from the below link. 
 
 
 
Regards, 
Divakar. 
 


K Guptha
Replied On February 7, 2017 07:23 AM UTC

Thanks for your reply, here I would like to display that CustomerID as below :
Customer ID 

is this possible like this.

Divakar Subramaniam [Syncfusion]
Replied On February 7, 2017 02:10 PM UTC

Hi Kumar, 
 
 
It is not possible to achieve your requirement in SfDataGrid directly. However, you can achieve it by using HeaderTemplate by loading two labels. Please refer the below code snippet. 
 
<sfGrid:GridTextColumn Width="100" MappingName="CustomerID"> 
    <sfGrid:GridTextColumn.HeaderTemplate> 
        <DataTemplate> 
            <StackLayout Orientation="Horizontal"> 
                <Label FontAttributes="Bold" 
                       HorizontalTextAlignment="Center" 
                       Text="Customer" 
                       TextColor="Black" 
                       VerticalTextAlignment="Center" /> 
                <Label HorizontalTextAlignment="Center" 
                       Text="ID" 
                       TextColor="Blue" 
                       VerticalTextAlignment="Center" /> 
            </StackLayout> 
        </DataTemplate> 
    </sfGrid:GridTextColumn.HeaderTemplate> 
</sfGrid:GridTextColumn> 
 
 
Also, I have attached a working sample for your reference and you can download the same from the below link. 
 
 
 
Regards, 
Divakar.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;