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. Image for the cookie policy date
close icon

DateTimeOffset Property Databinding

Hi there,

In a project I am working on there are classes with DateTimeOffset properties which needs to be displayed on controls like Grid and DateTimePicker etc.

I have noticed that when I am editing the columns bound to these properties data seems to be not displaying and while saving data is not displaying the new value on the column.  However I can see the data is actually changed and able to see the change via BatchUpdate method.

I have attached couple of screen shots along with this thread with Pre and Post user change of the field.

Is there a way to display DateTimeOffset field as corresponding local date/time while also able to display the updated value within the column.

Are there any issues with DateTimeOffset properties being bound to other MVC controls?

Also what is the best way to display DateTime/DateTimeOffset in local format (e.g. 31/12/2001 but not 12/31/2001)

Regards
Prasanth



Attachment: Grid_DateTimeOffset_Column_c239ea20.zip

3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team January 19, 2016 11:40 AM UTC

Hi Prasanth,

Thanks for contacting Syncfusion support.



     Queries
       Response
“While editing the columns proper data not displaying”

We have created a sample in batch editing with DateTimeOffset properties and we are able to display proper data while editing the columns.

public DateTimeOffset? OrderDate

        {

            get;

            set;
        }



Please find the screenshots:


 

After Editing:

 


“While saving the data the new date is not displayed”

While saving the data, we are able to get the new date in the date column.

Please find the screenshot:

 

“To display the datetime in local format”

To mention the datetime in local format, we suggest you to use Format API in the columns of ejGrid.

Please find the code example:

col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Format("{0:MM/dd/yyyy hh:mm:ss}").EditType(EditingType.DateTimePicker).Add();


Refer the below link for the various types of formats

Link : https://mvc.syncfusion.com/demos/web/grid/columnformatting

Sample: https://www.syncfusion.com/downloads/support/forum/121703/ze/Sample1105674821




Please provide the following details it will help us to reproduce the mentioned issue.


1.       Share the code example.

2.       Share the screenshot of an issue, if you face any script errors while editing the columns.


3.       Essential Studio version details.


Regards,
Prasanna Kumar N.S.V



PR Prasanth January 19, 2016 12:37 PM UTC

Hi Prasanna,

Thanks for the source code.  The issues seems to be related to format not being specified.  Soon as I added the foll0wing the issues I have mentioned disappeared.

.Format("{0:dd/MM/yyyy hh:mm:ss}")

Previously I didn't specify any formatting details.  Thanks again

Regards
Prasanth


PK Prasanna Kumar Viswanathan Syncfusion Team January 20, 2016 04:33 AM UTC

Hi Prasanth,
 
We are happy that the provided solution working fine at your end. 
 
Regards,

Prasanna Kumar N.S.V


Loader.
Live Chat Icon For mobile
Up arrow icon