Datepicker Formatter in dd/mm/yyyy

Posted by: khauam.cardoso on 6 May 2024, 1:52 am EST

  • Posted 6 May 2024, 1:52 am EST

    hi, when i set culture

    culture.DateTimeFormat.shortDatePattern = "dd/MM/yyyy";
    

    and put datepicker

    var style = new GC.Spread.Sheets.Style();
              style.cellButtons = [
                {
                  imageType: GC.Spread.Sheets.ButtonImageType.dropdown,
                  command: 'openDateTimePicker',
                  useButtonStyle: false,
                },
              ];
              style.dropDowns = [
                {
                  type: GC.Spread.Sheets.DropDownType.dateTimePicker,
                  option: { showTime: false},
                },
              ];
              style.formatter = 'dd/mm/yyyy';
              sheet.setStyle(linha, coluna, style);
    


    when a choose a day before day 12 the month and day invert

    exemple: i choose 02/01/2024 the spreed set 02/01/2024 wrong

    i choose 13/01/2024 the spreed set 13/01/2024 correct

    using angular 16 with spread 17.0.4

  • Posted 6 May 2024, 9:14 pm EST - Updated 6 May 2024, 9:19 pm EST

    Hi,

    Based on my understanding, it seems you’re encountering a problem when switching cultures and using the date picker. In some cases, when you select a date, it appears that the date switches to the month and the month switches to the date.

    I’ve been able to reproduce this issue on my end. After investigating, I discovered that you need to also set the “defaultDatePattern” in the culture object so that the date picker functions correctly. Please refer to the attached snippet, GIF named “date.gif,” and the provided sample for more clarity.

    // adding defining custom culture
    const myCulture = new GC.Spread.Common.CultureInfo();
    myCulture.DateTimeFormat.shortDatePattern = "dd/MM/yyyy";
    (myCulture as any).DateTimeFormat.defaultDatePattern = "dd/MM/yyyy";
    //add culture
    GC.Spread.Common.CultureManager.addCultureInfo("de-DE", myCulture);
    GC.Spread.Common.CultureManager.culture('de-DE');

    Gif:

    Sample: Sample.zip

    Regards,

    Priyam

Need extra support?

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

Learn More

Forum Channels