SfDataGrid Styling
We have analyzed your query and it is not possible to implement style for GridColumns. You have to set the values directly in the GridColumns as like in below code example.
|
<syncfusion:SfDataGrid x:Name="sfgrid" AutoGenerateColumns="False" ShowGroupDropArea="True" ItemsSource="{Binding OrderList}"> <syncfusion:SfDataGrid.Columns> <syncfusion:GridDateTimeColumn MappingName="OrderDate" TextAlignment="Center" Pattern="ShortDate"/> <syncfusion:GridCurrencyColumn MappingName="UnitPrice" TextAlignment="Right" CurrencyGroupSeparator="," CurrencyGroupSizes="3" AllowGrouping="True"/> |
When you are using SfDataGrid.AutoGenerateColumns as true, you have to use SfDataGrid.AutoGeneratingColumns event to initialize the required properties.
|
sfgrid.AutoGeneratingColumn += Sfgrid_AutoGeneratingColumn;
private void Sfgrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnArgs e) { if(e.Column is GridCurrencyColumn) { var currencyColumn = e.Column as GridCurrencyColumn; currencyColumn.CurrencyDecimalSeparator = ","; currencyColumn.TextAlignment = TextAlignment.Center; currencyColumn.CurrencyGroupSizes = new Int32Collection() {3, 2}; } |
For more information about GridColumns, please refer the before links.
http://help.syncfusion.com/wpf/sfdatagrid/columns
http://help.syncfusion.com/wpf/sfdatagrid/columns#defining-columns
http://help.syncfusion.com/wpf/sfdatagrid/column-types#gridcurrencycolumn
http://help.syncfusion.com/wpf/sfdatagrid/column-types#griddatetimecolumn
Please let us know if you require further assistance on this.
Regards,
Antony Raj
We have analyzed your query and we have checked the TextAlignment and AllowGrouping property of GridColumns which is working fine from our side. You have to set Width more than the cell size to make effect on TextAlignment property. And you have to set CurrencyGroupSeperator with equal to operator as like the below code example.
XAML:
|
<syncfusion:SfDataGrid x:Name="grid" ItemsSource="{Binding OrderInfoCollection}" AllowResizingColumns="True" ColumnSizer="Auto" <syncfusion:GridCurrencyColumn MappingName="Note" HeaderText="Retail Rate" Width="300" TextAlignment="Right" CurrencyGroupSizes="3" CurrencyGroupSeparator="," <syncfusion:GridDateTimeColumn MappingName="Date" TextAlignment="Center" HeaderText="Till" Width="100"
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid> |
We have prepared a sample as per your scenario and you can download the same from the below location,
Sample: http://www.syncfusion.com/downloads/support/forum/123321/ze/Samples-905390982
Please refer the below link to know more GridCurrencyColumn.
Link: http://help.syncfusion.com/wpf/sfdatagrid/column-types#gridcurrencycolumn
Regards,
Srinivasan
Thanks for your replyChanged code as per your suggestion and found Only TextAlignment is not working (every thing is aligned Left)Sample you supplied is working perfectly so I think there is something wrong in my project itself, So can you please tell me where to look for problemThanks in advanceAmit Saraf
Figured out the problem
We are glad that your issue has been fixed.
Please let us know if you need any other assistance.
Regards,
Ashwini P.
- 6 Replies
- 4 Participants
-
AS Amit Saraf
- Mar 8, 2016 06:17 AM UTC
- Mar 11, 2016 09:57 AM UTC