We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

sfdatagrid DateTimeOffset support in GridDateTimeColumn

Thread ID:

Created:

Updated:

Platform:

Replies:

124853 Jul 4,2016 01:33 PM UTC Jul 6,2016 01:59 PM UTC UWP 4
loading
Tags: SfDataGrid
Balasubramanian Ramanathan
Asked On July 4, 2016 01:33 PM UTC

Hi,

If the model contains datetimeoffset column then while adding or editing it throws up an error.

Whether datetimeoffsetcolumn is supported in uwp sfdatagrid?

If not how to make it work with datetimeoffset column.

Thanks

Balasubramanian Ramanathan
Replied On July 4, 2016 02:09 PM UTC

I managed to find the example in your help system.

Thank you

Jai Ganesh S [Syncfusion]
Replied On July 5, 2016 04:36 AM UTC

Hi Balasubramanian, 
 
Thank you for the update. 
 
Please let us know if you need any other assistance on this. 
 
Regards, 
Jai Ganesh S 
 


Balasubramanian Ramanathan
Replied On July 5, 2016 02:23 PM UTC

Thank you for the reply.

I am facing issues with having nullable datetimeoffset field.

How to modify the converted class to handle nullable datetimeoffset file in the model.

Thanks.

Jai Ganesh S [Syncfusion]
Replied On July 6, 2016 01:59 PM UTC

Hi Balasubramanian, 
 
You can achieve your requirement to bind the null value in DateTimeOffset by change the converter like below, 
 
public class DateTimeOffsetFormatConverter : IValueConverter 
{ 
    private GridDateTimeOffsetColumn cachedColumn; 
 
    public DateTimeOffsetFormatConverter(GridDateTimeOffsetColumn column) 
    { 
        cachedColumn = column; 
    } 
 
    object IValueConverter.Convert(object value, Type targetType, object parameter, string language) 
    { 
 
        var column = cachedColumn as GridDateTimeColumn; 
           
        if (value == null || DBNull.Value == value) 
        { 
            if (column.AllowNullValue) 
                return column.WaterMark; 
        } 
             
        value = ((DateTimeOffset)value).DateTime; 
 
 
        DateTime _columnValue; 
 
        _columnValue = (DateTime)value; 
 
        if (_columnValue < column.MinDate) 
            _columnValue = column.MinDate; 
 
        if (_columnValue > column.MaxDate) 
            _columnValue = column.MaxDate; 
 
        return _columnValue.ToString(column.FormatString, CultureInfo.CurrentUICulture); 
    } 
 
    object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language) 
    { 
        throw new NotImplementedException(); 
    } 
} 
 
 
Regards, 
Jai Ganesh S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;