Hi Karthi Chandra
Thanks for contacting Syncfusion support.
We are little unclear with your requirement. However we suspect that your requirement is to define DataTemplate for the columns in the SfDataGrid(like GridTextColumn, GridNumericColumn). So that once you defined the column with some properties, you can use the same template to create several columns with same values for those properties. If this is your requirement, it is not possible to define DataTemplate for the columns, as they are not an UI element. You can achieve this requirement by creating custom column types derived from existing column types as use the custom type for creating the column as shown below.
Code example :
|
public class GridTextColumnExt : GridTextColumn
{
public GridTextColumnExt()
{
this.AllowFiltering = false;
this.GroupMode = Syncfusion.Data.DataReflectionMode.Display;
}
}
public class GridNumericColumnExt : GridNumericColumn
{
public GridNumericColumnExt()
{
AllowEditing = false;
this.NumberDecimalDigits = 2;
this.NumberDecimalSeparator = "'";
this.GroupMode = Syncfusion.Data.DataReflectionMode.Display;
}
}
<syncfusion:SfDataGrid.Columns>
<local:GridTextColumnExt MappingName="FirstName" />
<local:GridTextColumnExt MappingName="LastName" />
<local:GridNumericColumnExt MappingName="ID"/>
<local:GridTextColumnExt MappingName="Title" />
<local:GridNumericColumnExt MappingName="Salary" />
</syncfusion:SfDataGrid.Columns> |
Please revert to us with more create details about your requirement if we have misunderstood your requirement. It will be more helpful for us to understand the exact requirement and to provide a prompt solution at earlier.
Regards,
Mohanram A.