Search code examples
infragisticsignite-ui

How to send a date with offset to the server while adding a new entry into Ignite UI ig.Grid table


I'm using Ignite Ui 16.1 igGrid with RESTDataSource. Please, consider following configuration of one of the grid's columns:

{
                   headerText: $.i18n._("From"),
                    key: "start",
                    validation: true,
                    required: true,
                    dataType: "date",
                    editorType: "date",
                    format: "HH:mm",
                    editorOptions: {
                        validatorOptions: {
                            dateInputFormat: "HH:mm",
                            OnBlur: true,
                            OnChange: true
                        }
                    },
                    readOnly: false
}

When a new row is adding, in the payload of the post/create request start:"/Date(1470636037642)/" is sent to the server, which is parsed by the default MVC model binder as UTC date. This is absolutly in unison with Ignite Ui documentation that states all dates are sent in UTC.

Could you, please, point me out, how to configure this column, so a date with an offset to be sent to the server. I would like to know user's timezone. Thanks in advance!


Solution

  • You can add the timezone offset info manually in the transaction object.

    features: [
        { 
            name: "Updating",
            editRowEnding: function(evt, ui) {
                ui.values["offset"] = ui.values["CreateDate"].getTimezoneOffset();
            }
        }
    ]
    

    If you use igGrid MVC Wrapper to deserialize the transaction log you will need to add an additional field (in this case named "offset") to your model.