JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script src="http://www.jeasyui.com/easyui/jquery.edatagrid.js"></script>
<div id="dg"></div>
JavaScript
$.fn.datetimebox.defaults.formatter = function (date) {
console.log('dt formatting '+date);
if (!(date instanceof Date)) date = new Date(date);
var h = date.getHours();
var M = date.getMinutes();
var s = date.getSeconds();
function _ff(v) {
return (v < 10 ? "0" : "") + v;
};
return _ff(date.getFullYear())+'-'+_ff(date.getMonth()+1)+'-'+date.getDate() + ' ' + _ff(h)+':'+_ff(M)+':'+_ff(s);
};
$.fn.datetimebox.defaults.parser = function (s) {
console.log('dt parsing '+s);
if ($.trim(s) == "") {
return new Date();
}
var dt = s.split(" ");
var p1 = dt[0].split('-');
var p2 = dt[1].split(':');
return new Date(p1[0],p1[1]-1,p1[2],p2[0],p2[1],p2[2]);
};
// now the editable datagrid
$('#dg').edatagrid({
title: "date edit test",
singleSelect: true,
fit: true,
iconCls: 'icon-edit',
autoRowHeight: false,
fitColumns: false,
saveUrl: '/save.php',
updateUrl: '/update.php',
destroyUrl: '/destroy.php',
columns: [
[{
field: 'id',
title: 'id',
width: 40,
editor: {
type: 'text',
options: {
disabled: false,
required: true,
novalidate: true
}
}
}, {
field: 'date',
title: 'Date',
width: 200,
editor: {
type: 'datetimebox',
options: {
multiple: false,
novalidate: true
}
}
}]
],
data: [{
"id": "1",
"date": "2014-05-03T12:54:46"
}, {
"id": "2",
"date": "1996-02-03T12:54:46"
}, {
"id": "3",
"date": "2000-12-31T00:00:00"
}],
loadFilter:function(data){
if ($.isArray(data)){
data = {
total:data.length,
...