Skip to content

Infragistics Community Forum / Web / Ignite UI for Angular / Igx-grid column data type "date"

Igx-grid column data type "date"

New Discussion
DUFEIL Philippe
DUFEIL Philippe asked on Sep 1, 2022 8:20 AM

Hello,
I have a strange behaviour when I am creating a row in a cell of type "date".
I have formatted the column to have a short date in French format.
When I create a new cell, when I leave the cell, it is formatted in English with a Day-1 date stored in the database.

I don't understand.
Do you have any suggestions ?

— HTML     
<igx-column field="DTACHAT" header="Dt Achat" [pinned]=true [filterable]=false width=150  [dataType]="'date'" [pipeArgs]="formatDateOptions"  > </igx-column>
—- TS
  public optionsDate = {
    format: 'shortDate',
    timeZone: '+0200',
    locale : 'fr-FR'
  }
 
  public formatDateOptions = this.optionsDate
Best regards,
Philippe DUFEIL
Sign In to post a reply

Replies

  • 0
    Ivan Kitanov
    Ivan Kitanov answered on Aug 31, 2022 10:26 AM

    Hello Phelippe, 

    I have tried to reproduce this behavior, by using the same date format for the column as well as setting a French locale for the grid, however when a new row is added and the cell with the date is left empty its value is stored as undefined. I believe this might be the reason you are getting Day-1 stored in your database, it might be the way how your database handles undefined values, what it could be done is handling the rowAdded event and checking if the value of the cell is equal to undefined and instead store this value as null or a value that your database could handle.

    Here, you can find the sample that I have tested with, please test the sample on your side and let me know if it is able to replicate the scenario that you are facing. In case it doesn’t please modify the sample or provide your own that reproduces the issue.

    Looking forward to hearing from you.

    Regards,
    Ivan Kitanov

    • 0
      DUFEIL Philippe
      DUFEIL Philippe answered on Sep 1, 2022 8:19 AM

      Hello Ivan,
      I have solved the problem. In fact, I used the JSON.stringify statement in the "rowEditDone" method.
      JSON.stringify changes the time of the date because of UTC with JavaScript.
      Using the toLocaleDateString() function beforehand, this corrects the date change.

      Regards,

      Philippe DUFEIL

      • 0
        Ivan Kitanov
        Ivan Kitanov answered on Sep 1, 2022 8:20 AM

        Hello Philippe,

        I'm glad that you were able to resolve your issue.

        Thank you for choosing Infragistics!

        Regards,
        Ivan Kitanov

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
DUFEIL Philippe
Favorites
0
Replies
3
Created On
Sep 01, 2022
Last Post
3 years, 6 months ago

Suggested Discussions

Created by

Created on

Sep 1, 2022 8:20 AM

Last activity on

Sep 1, 2022 8:20 AM