Flexgrid parse date strings before rendering

Posted by: scott.chinn on 30 March 2020, 3:38 am EST

  • Posted 30 March 2020, 3:38 am EST

    Hello,

    We made a react grid wrapper control around Flexgrid that is used in many of app’s screens. Sometimes the screens that use the control use an itemSource that has columns with date strings (time in millisecs) vs objects. This then causes trouble because the date formatting doesn’t work with date. Is there a generic way I can convert the date string columns from itemSource before the grid renders?

    I guess I just need an event that fires after the data model is create but before rendering happens, then I can loop through the date string columns and convert them to date objects.

    If there is a way to tell flexgrid to just use date strings for certain columns (like having a DATE_STRING data type), that would be ideal if it was just handled automatically. I know there isn’t so simple but I know dhtmlxgrid is able to do it.

    Thanks!

  • Posted 30 March 2020, 8:12 pm EST

    Hi Scott,

    You can use the JSON.parse method before assigning the data source to the FlexGrid. The JSON.parse method have a reviver callback that can be used to convert the string dates into a Date object:

    https://www.grapecity.com/wijmo/demos/Core/CollectionView/LoadingData/LoadingJSONDates/react

    In Wijmo’s FlexGrid, there is a dataType property for each Column that can be used to set the data type but it will not be of any use in your scenario because it does not actually sets the data type of that Column but tries to coerce the edited value into that particulate type.

    This means that the dates will be parsed, if they can, only when the data is edited.

    Regards,

    Ashwin

  • Posted 1 April 2020, 12:47 am EST

    Thanks, this was very help.

Need extra support?

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

Learn More

Forum Channels