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
close icon

How to change header text in grid?

I have the datagrid preview bound to an observable collection.  The columns do not show unless I have autogenerate columns ticked, which  then assigns the property name from the model, which is nice, but is not what I would like the end user to see.

3 Replies

PS Prakash Selvaraj Syncfusion Team March 4, 2013 09:51 AM UTC

Hi Gary,

 

Thank you for choosing Syncfusion Controls.

 

We have analysed your query, if you set AutoGenerateColumns as true, then the Grid will populate the columns automatically according to the Data present in the Model and HeaderText  will also be automatically set to the GridColumns. If you want to set the HeaderText as per your desire then  you need to define the GridColumns as in the below code snippet.

 

Code Snippet [Xaml]:

<syncfusion:SfDataGrid.Columns>

  <syncfusion:GridTextColumn HeaderText="ID" MappingName="EmployeeId" />

  <syncfusion:GridTextColumn HeaderText="Name" MappingName="EmployeeName" />

  <syncfusion:GridTextColumn HeaderText="Title" MappingName="EmployeeDesignation" />

</syncfusion:SfDataGrid.Columns>

 

Please let us know if you need further assistance.

 

Regards,

Prakash S.



GP Gary Pansino March 4, 2013 04:08 PM UTC

Thank you.  Very helpful.

A related question ... how do you hide/show columns?  


PS Prakash Selvaraj Syncfusion Team March 5, 2013 10:59 AM UTC

Hi Gary,

 

We have analysed your query. You can achieve your requirement by setting true/false to IsHidden property in GridColumns. Please refer the following code snippet.

 

Code Snippet [C#]:

 

<syncfusion:SfDataGrid.Columns>

                <syncfusion:GridTextColumn HeaderText="Id"

                                           IsHidden="False"

                                           MappingName="EmployeeId" />

                <syncfusion:GridTextColumn HeaderText="Name"

                                           IsHidden="True"

                                           MappingName="EmployeeName" />

                <syncfusion:GridTextColumn HeaderText="Title"

                                           IsHidden="False"

                                           MappingName="EmployeeDesignation" />

</syncfusion:SfDataGrid.Columns>

 

Please let us know if you need further assistance.

 

Regards,

Prakash S.


Loader.
Live Chat Icon For mobile
Up arrow icon