Date/Time Format

Posted by: grapecity on 5 October 2017, 8:54 am EST

    • Post Options:
    • Link

    Posted 5 October 2017, 8:54 am EST

    My json file contains a colum with DateTime as 2017-09-25T00:00:00.000Z

    My Flexgrid is declared as:

    <wj-flex-grid #flex

    [autoGenerateColumns]=“true”

    [headersVisibility]=“1”

    [allowSorting]=“true”

    [itemsSource]=“filterData”

    [selectionMode]=“1”

    [showMarquee]=“true”

    [isReadOnly]=“true”

    [keyActionTab]=“3”

    (formatItem)=“formatItem(flex,$event)”

    (initialized)=“initFlex(flex)”

    (loadedRows)=“loadedRows(flex)”

    (dblclick)=“onDoubleClick(flex,$event)”

    (selectionChanged)=“onSelectionChanged(flex)”

    (mousedown)=“mouseDown($event)”

    (mouseout)=“mouseOut($event)”

    (mousemove)=“mouseMove($event)”>

        <wj-flex-grid-filter
          [filterColumns]="['teamMemberLeader',
                            'teamMemberName',
                            'tradeCategory',
                            'tradeSubCategory']">
        </wj-flex-grid-filter>
      </wj-flex-grid>
    

    What is the appropriate way to format the above datetime into “mm/dd/yyyy” to be displayed on the grid. Thank you very much.

  • Posted 8 October 2017, 6:24 pm EST

    Hi Hoang,

    We are sorry for the late reply.

    The date is string data type. You need to parse to date using date column it to date before binding to the FlexGrid.

    
    var dt= "2017-09-25T00:00:00.000Z";
    var dDate= new Date(dt);
    
    

    ~Manish Kr Gupta

  • Posted 9 October 2017, 2:34 am EST

    Thank you sir. If I change my [autoGenerateColumns]=“false” and declare my column in html module as:

    <wj-flex-grid-column

    [header]=“‘Date’”

    [binding]=“‘calendarDate’”

    [width]=“‘*’”

    [wordWrap] = “true”>

    How do I format date/time here sir?

  • Posted 9 October 2017, 4:35 pm EST

    Hi Hoang,

    You need to parse JSON before binding to FlexGrid for date values as mentioned in previous reply. Once date string is parsed as Date. You can format date column in required date format by setting format property for the column.

    Please refer to the code for column directive:

    <wj-flex-grid-column [binding]="'date'" [format]="'MM/dd/yyyy'"></wj-flex-grid-column>
    

    ~Manish Kr Gupta

  • Posted 11 October 2017, 5:40 am EST

    Thank you sir

  • Posted 29 September 2018, 12:50 pm EST

    Hi Manish,

    Will Filter work for this formatted value for Date i am having issues with filter formatted value?

  • Posted 30 September 2018, 3:40 pm EST

    Hi,

    The filter works fine with the formatted value. Can you please let us know what issues you are facing?

    ~Sharad

  • Posted 1 October 2018, 1:26 am EST

    Hi Sharad,

    I was able to get the formatted value filter working it was issue on my side with data

    Thanks

Need extra support?

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

Learn More

Forum Channels