- Home
- Forum
- Xamarin.Forms
- How to customize the sfdatagrid header text font style ?
How to customize the sfdatagrid header text font style ?
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 ?
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 ?
SIGN IN To post a reply.
3 Replies
DS
Divakar Subramaniam
Syncfusion Team
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.
KG
K Guptha
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.
DS
Divakar Subramaniam
Syncfusion Team
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.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
KG K Guptha
- Feb 7, 2017 12:47 AM UTC
- Feb 7, 2017 02:10 PM UTC