FlexGrid Format doesn't show slash in dates

Posted by: andy.richard on 16 June 2023, 1:07 am EST

  • Posted 16 June 2023, 1:07 am EST

    I’m using the Format property of the FlexGrid GridColumn to format the date like this: 8/26/2023 08:56:22 PM. So Format=“m/dd/yyyy hh:mm:ss tt” but this is how the date gets formatted when I run the application: 8-26-2023 08:56:22 PM. Can you help?

  • Posted 20 June 2023, 12:06 am EST - Updated 20 June 2023, 12:11 am EST

    Hi Andy,

    I tested the Column Format at my end and it seems to be working fine at my end. The format depends on the culture localization. Please make sure of the following two things:

    1. You are using the GridDataTimeColumn when defining the column of the FlexGrid.
    <GridDateTimeColumn Binding="LastOrderDate" Format="m/dd/yyyy hh:mm:ss tt"
                                Mode="GridDateTimeColumnMode.Date" MinWidth="160" Width="GridLength.Star"
                                HorizontalAlignment="C1HorizontalAlignment.Right"
                                HeaderHorizontalAlignment="C1HorizontalAlignment.Right" />
    1. You are adding the culture supporting the format (applied in the Program.cs file).
    // Allowed using of date, number formats for all available cultures.
    var allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures).Select(c => c.Name).ToArray();
    var localizationOptions = new RequestLocalizationOptions()
        .AddSupportedCultures(allCultures)
        .AddSupportedUICultures(allCultures)
        .SetDefaultCulture("en");
    app.UseRequestLocalization(localizationOptions);

    References:

    GridDateTimeColumn Class: https://www.grapecity.com/componentone/docs/blazor/online-blazor/C1.Blazor.Grid~C1.Blazor.Grid.GridDateTimeColumn.html

    Column Definition Demo: https://www.grapecity.com/componentone/demos/blazor/blazorexplorer/FlexGrid/ColumnDefinitions

    Regards,

    Ankit

    Sample: Date_Format.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels