Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Igx-Grid: Convert datatypes - string to date
posted

Hello,

I have an igx-grid with a column with dates. When I try to filter the columns with the dates nothing changes. Maybe it's because I got the data from SQL database in a string format. Is it possible to display those dates from the original string format as a date format in the igx grid?

I read a similar question in the forum: https://ko.infragistics.com/community/forums/f/ignite-ui-for-angular/121906/custom-string-date-filter

Since the question was posted over 2 years ago, I would like to know if this problem is already solved and if there is a solution to it.

I tried to convert the string into a date:

      for (let d = 0; d < this.myData.length; d++) {
        let currentDate= this.myData[d].orderDate
        let day = currentDate.substring(0, 2)
        let month = currentDate.substring(3, 5)
        let year = currentDate.substring(6, 10)

        this.myData[d].orderDate= month + "." + day + "." + year
        let convertedDate= new Date(year + '-' + month + '-' + day)
        this.myData[d].orderDate= convertedDate
      }

This is my igx-column:

    <igx-column width="112px" field="orderDate"
                [dataType]="'date'"
                [pipeArgs]="formatDateOptions"
                header="Order Date" [resizable]="true" [sortable]="true" [editable]="false" [movable]="true" [cellClasses]="greenRowLotClass">
    </igx-column>

And here is my [pipeArgs]:

  public dateOptions = {
    format: 'mediumDate',
    timezone: 'UTC+0'
  };
  public formatDateOptions = this.dateOptions;

Thank you in advance.