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

Some questions about DataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

143377 Mar 18,2019 02:56 AM UTC Mar 18,2019 01:17 PM UTC WPF 1
loading
Tags: SfDataGrid
John
Asked On March 18, 2019 02:56 AM UTC

I've few questions about SdDataGrid.

How to align cell value to center ?
How format cell value without using a different property ? Like cell value appear "123" and I want it to show "123 Kg". Like binding with StringFormat.
How to make a column to fill the rest of space? Like there are 3 columns, and I want second column to fill the space.
How to hide a column without setting its width to 0 ?

Shobika Palani [Syncfusion]
Replied On March 18, 2019 01:17 PM UTC

Hi Xmen, 

Thanks for contacting Syncfusion Support. 

We have analyzed your query and you can find answers for your queries from the below table 

Query 
Answer 
How to align cell value to center ? 

We have analyzed your query to change the alignment of cells in SfDatGrid and you can achieve this by using the following ways.  
  
Case 1 : If you want to use same alignment to all the cells in a grid, refer to following code snippet  
  
  
<Style TargetType="syncfusion:GridCell" >  
   <Style.Resources>  
       <Style TargetType="TextBlock">  
           <Setter Property="HorizontalAlignment" Value="Center"/>  
       </Style>  
   </Style.Resources>  
</Style>  
  
  
Note :  
By using the above solution, horizontal alignment will not be changed for the below columns  
  • GridComboBoxColumn
  • GridTemplateColumn
  • GridCheckBoxColumn
  • GridImageColumn
  
Case 2 : If you want to use different alignment for different columns, you can make use of GridColumn.TextAlignment property. Please refer to following code snippet  
  
  
<syncfusion:GridTextColumn MappingName="OrderID" TextAlignment="Center"/>  
  
  
 
How format cell value without using a different property ? Like cell value appear "123" and I want it to show "123 Kg". Like binding with StringFormat. 
 
You can achieve this by writing DisplayBinding for the specific column. Please refer to the below KB article to know more details on formatting cell value 

KB Link: 

Also please refer to the below UG Link 
UG Link: 
How to make a column to fill the rest of space? Like there are 3 columns, and I want second column to fill the space. 
 
You can set column sizer of specific column as AutoLastColumnFill or AutoWithLastColumnFill.  

Please refer to the below UG link for more details 
UG Link: 
How to hide a column without setting its width to 0 ? 
 
By default, we will set column width as 0 when you hide the column. Can you please let us know why you do not want to make the column width as 0 while hiding? 
                                                                                                                                               
Please let us know, if you need any further assistance on this. 
 
Regards, 
Shobika. 


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.

Please sign in to access our forum

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon