jQWidgets Forums
jQuery UI Widgets › Forums › Grid › after editing date field,the value is changed.
Tagged: date format
This topic contains 2 replies, has 2 voices, and was last updated by nove 2 years, 10 months ago.
-
Author
-
Hi,
I use jqxGrid of jQWidgets v14.0.0 (2022-May).
The grid have date field.$(“#jqxgrid”).jqxGrid({
width: 400,
selectionmode: ‘singlecell’,
source: dataadapter,
theme: theme,
editable: true,
autoheight: true,
height:window.innerHeight-200,
pageable: false,
virtualmode: true,rendergridrows: function(obj){
return obj.data;
},columnsresize:true,
columns: [
{ text: ‘weekcode’, editable: false, datafield: ‘weekcode’, width: 100,cellsalign:”center” },
{ text: ‘startday’, datafield: ‘startday’, width: 100,cellsformat:”yyyy/MM/dd”,columntype:”textbox” }, // <— this column
]}
);When I start editing,the value is displayed correctly.
But When I press Enter Key to finish editing,the value is changed to wrong value,
the value of month and day is exchanged.For example,
Before I finished editing the value is like 2022/4/3
But after pressing enter key,the value is changed like 2022/3/4.Is there any additional setting?
Sincerely,
HTML like
<head>
<link href=”css/normalize.css” rel=”stylesheet”>
<link href=”css/bootstrap.min.css” rel=”stylesheet”><link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.classic.css” type=”text/css” />
<script src=”js/jquery-3.6.0.min.js”></script>
<script src=”js/funcs.js”></script>
<script src=”jqwidgets/jqxcore.js”></script>
<script src=”jqwidgets/jqxbuttons.js”></script>
<script src=”jqwidgets/jqxscrollbar.js”></script>
<script src=”jqwidgets/jqxmenu.js”></script>
<script src=”jqwidgets/jqxcheckbox.js”></script>
<script src=”jqwidgets/jqxlistbox.js”></script>
<script src=”jqwidgets/jqxdropdownlist.js”></script>
<script src=”jqwidgets/jqxgrid.js”></script>
<script src=”jqwidgets/jqxdata.js”></script>
<script src=”jqwidgets/jqxgrid.selection.js”></script>
<script src=”jqwidgets/jqxgrid.edit.js”></script>
<script src=”jqwidgets/jqxgrid.pager.js”></script>
<script src=”jqwidgets/jqxgrid.columnsresize.js”></script>
</head>
<body>
<div id=”jqxgrid”>
</div>
<script src=”js/xxx.js”></script> //<– load js
</body>
</html>xxx.js is like
(I get datas from my site.)$(document).ready(function () {
// prepare the data
var data = {};
var theme = ‘classic’;
var source ={
datatype: “json”,
datafields: [
{ name: ‘weekcode’, type: ‘number’},
{ name: ‘startday’, type: ‘date’,format:”yyyy/MM/dd”}, // <— this value is displayed correctly , when this data is loaded.
],
id: ‘weekcode’,
url: ‘php/db/mntWeek.php’,
root: ‘Rows’,
cache: false,beforeprocessing: function(data){
source.totalrecords = data[0].TotalRows;
},};
var dataadapter = new $.jqx.dataAdapter(source);
// initialize jqxGrid
$(“#jqxgrid”).jqxGrid({
width: 400,
selectionmode: ‘singlecell’,
source: dataadapter,
theme: theme,
editable: true,
autoheight: true,
height:window.innerHeight-200,
pageable: false,
virtualmode: true,rendergridrows: function(obj){
return obj.data;
},columnsresize:true,
columns: [
{ text: ‘weekcode’, editable: false, datafield: ‘weekcode’, width: 100,cellsalign:”center” },
{ text: ‘startday’, datafield: ‘startday’, width: 100,cellsformat:”yyyy/MM/dd”,columntype:”textbox” },
]}
);$(“#jqxgrid”).on(“cellendedit”,function (event) {
var args = event.args; // <– args.oldvalue is correct,but value is wrong
console.log(args);
var columnDataField = args.datafield;
var rowIndex = args.rowindex;
var cellValue = args.value;
var oldValue = args.oldvalue;
});
});Hi nove,
Thank you for reporting reporting the problem. I have created a work item and we will work on fixing it as soon as possible.
As a workaround, you can try using a different date format such as:
cellsformat: 'd'
orcellsformat: 'dd-MM-yyyy'
Best Regards,
Ivan Peevski
jQWidgets Team
https://www.jqwidgets.com/Thank you,ivanpeevski.
I need format ‘yyyy/mm/dd’.
Because user of ‘dd-MM-yyyy’ is very fiew,in japan.Now I use “geteditorvalue” of columns.
Like { text: ‘開始日’, datafield: ‘startday’, cellsformat:”yyyy/MM/dd”,
geteditorvalue: function (row, cellvalue, editor) {
return editor[0].value;
},
},I expect your fixing work.
Sincerely,
-
AuthorPosts
You must be logged in to reply to this topic.