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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridTemplateColumn header width

Thread ID:





121821 Jan 28,2016 02:00 PM UTC Feb 1,2016 12:50 PM UTC UWP 3
Tags: SfDataGrid
Asked On January 28, 2016 02:00 PM UTC


I use GridTemplateColumn in SfDataGrid.
ColumnSizer property of the grid sets to Auto.
When I set HeaderText property of the column to some value ("*" on the screenshot below) column header width looks good.
But if I remove HeaderText property and set HeaderTemplate property of the column to following simple value:

    <TextBlock Text="*" />

column header width becomes too large.

Please see screenshot:

How I can fix column header width in case of HeaderTemplate?


Ambarish Srinivasan [Syncfusion]
Replied On January 29, 2016 11:47 AM UTC

Hi Vladimir,

The Width of a column header will be calculated based on the MappingName and HeaderText of a column. In you case, width calculate based on MappingName. To overcome this problem either set Width or HeaderText property. If you set HeaderText property, then width will be calculated based on HeaderText property instead of MappingName.  


<DataTemplate x:Key="Header">

            <TextBlock Text="*" />

<syncfusion:GridTemplateColumn Width="30"

                               HeaderTemplate="{StaticResource Header}"
                               MappingName="OrderID" />


Replied On January 29, 2016 12:39 PM UTC

Yes, it seems that the width of the column header depends of MappingName. I think that a little strange, because I don't use MappingName in my HeaderTemplate in any way.
I don't want to set column width directly because column data is dynamic and width of data if variable. ColumnSizer="Auto" is the best choice for this case but (I think) algorithm should calculate HeaderTemplate width (after render it for real data) and sets width of the column accordingly.
In any case, thanks for beautiful DataGrid.

Ambarish Srinivasan [Syncfusion]
Replied On February 1, 2016 12:50 PM UTC

Hi Vladimir,

We have logged the issue report on "Header column width is too large when using HeaderTemplate in GridTemplateColumn" and this issue will be fixed in our upcoming Volume 4 Service pack 1 release which will be available by the mid of February, 2016. 




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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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