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
820
Convert UTC dates to Local Time - trying to update unbound column on datasource change
posted

I am trying to display UTC dates as local time in my grid.  I subclassed the grid, and have it add an unbound column for each date column to display the local time. I copy all the column settings to this column, and then rename and hide the original column. I calculate the local time inside 'OnInitializeRow'

It all works great.. until I update the datasource the grid is based on.  OnInitializeRow doesn't run and so the date stays at the old value.  Right now I added a function that gets manually called after I update the datasource to go through all the cells in the grid and update them if they are my unbound local time cells.

Is there a cleaner/faster/better way of doing this??  I really wish there was support in the infragistics controls to display dates according to the regional settings.. there is regional support for all the other editors and values.

 

Parents
No Data
Reply
  • 69832
    Offline posted

    jeffkov said:
    Is there a cleaner/faster/better way of doing this??  I really wish there was support in the infragistics controls to display dates according to the regional settings.. there is regional support for all the other editors and values.

    The problem you describe is not a function of regional formatting, but rather the conversion from UTC to local time. The date/time formatting properties exposed by the culture settings are not associated with a time zone, because there is not a one-to-one relationship between a time zone and a culture.

    The problem you are trying to solve here sounds like a good fit for the IEditorDataFilter interface (see the UltraGridColumn.Editor.DataFilter property). That interface gives you the opportunity to convert the values as they go back and forth from the editor to the cell. Your implementation would take the date/time as UTC, and convert it to local time before presenting it to the user, then convert back before assigning the value to the cell.

Children