A better way to solve this issue is to extend a new editor that can convert between long numeric and date value.
<script>
$.extend($.fn.datagrid.defaults.editors, {
datebox2: {
init: function(container, options){
var input = $('<input>').appendTo(container);
input.datebox(options);
return input;
},
destroy: function(target){
$(target).datebox('destroy');
},
getValue: function(target){
var opts = $(target).datebox('options');
var v = $(target).datebox('getValue');
return opts.parser.call(target,v).getTime();
},
setValue: function(target, value){
var opts = $(target).datebox('options');
var d = new Date(parseInt(value));
var s = opts.formatter.call(target, d);
$(target).datebox('setValue', s);
},
resize: function(target, width){
$(target).datebox('resize', width);
}
}
});
</script>
Please notice that the 'formatter' and 'editor' should be defined correctly on the datagrid column.
<th data-options="field:'datefield',width:100,
formatter:function(value,row){
if (value){
return new Date(parseInt(value)).toLocaleDateString();
}
},
editor:{
type:'datebox2',
options:{
}
}"> datefield </th>