Sorry to post in issues though it is not an issue with jsgrid. Could not find any forum.
I am trying to add custom field with datetime-local but having some issues.
Everything works fine but value returned by editValue is always current date and time. my code is as below only edit section:
$(function() {
var FoQusDateTimeField = function (config) {
jsGrid.Field.call(this, config);
};
FoQusDateTimeField.prototype = new jsGrid.Field({
sorter: function (date1, date2) {
return new Date(date1) - new Date(date2);
},
itemTemplate: function (value) {
if (value === null) {
return '';
} else {
return value;
// dates are alrready recived in YYYYMMDDThhmm format
}
},
editTemplate: function (value) {
formatedvalue=moment(value).format("YYYY-MM-DDThh:mm");
this._editPicker = $('<input type="datetime-local" value=' + formatedvalue+'>');
return this._editPicker;
},
editValue: function () {
var editValue= moment(this._editPicker.value).format("YYYY-MM-DDThh:mm:ss");
console.log(editValue); // always returns current date and time
if (typeof editValue !== 'undefined' && editValue !== null) {
return editValue;
} else {
return null;
}
}
});
jsGrid.fields.FoQusDateTimeField = FoQusDateTimeField;
```javascript
var editValue= moment(this._editPicker.value).format("YYYY-MM-DDThh:mm:ss");
should be
var editValue= moment(this._editPicker.val()).format("YYYY-MM-DDThh:mm:ss");
Sorry to post in issues though it is not an issue with jsgrid. Could not find any forum. I am trying to add custom field with datetime-local but having some issues. Everything works fine but value returned by editValue is always current date and time. my code is as below only edit section: