In the SfDataGrid, the GridDateTimeColumn provides support to display the date time value. You can set different cultures for the GridDateTimeColumn by using the property in the DisplayBinding and ValueBinding property of that column as shown in the following code example.
Two different cultures, fr-FR and en-US are defined to different GridDateTimeColumns. The GridDateTimeColumn value is displayed based on the pattern, by default. So, the ConverterCulture is not considered for the display mode.
Note: By default, short date pattern is applied to the GridDateTimeColumn.
To overcome this, you need to return culture formatted column value with the help of the converter in the DisplayBinding as shown in the following code example.
Based on the above culture, the GridDateTimeColumn is displayed in the following screenshot.
Figure 1: GridDateTimeColumn with different cultures
The above culture is set in the Display mode of the GridDateTimeColumn when you want to set the same culture format in the edit mode by deriving a new class from the GridCellDateTimeRenderer and overriding the OnInitializeEditElement virtual method.
The following code example illustrates the override of a new class from the existing GridCellDateTimeRenderer.
The DateTimeFormat is get from the corresponding column’s ValueBinding and assigned the DateTimeEdit UIelement that is loaded in the edit mode of the GridDateTimeColumn. Refer to the following code example to remove the default GridCellDateTimeRenderer and add the customized GridCellDateTimeRendererExt to the renderer’s collection in the SfDataGrid.
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:||.NET Framework:|