Hi,
I use dates in columns of my grids.
The format of dates in the source used to generate grid comes from sql, to the dates are in format : jj-mm-yyyy
here is a simple configuration :
var data = [{firstname: “bob”, date: ‘2022-09-06’}, {firstname: “kim”, date: ‘2022-09-05’}];
var source = {
localdata: data,
datafields: [{
name: ‘firstname’,
type: ‘string’
}, {
name: ‘date’,
type: ‘date’
}],
datatype: “array”
};
var adapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid({
width: 500,
height: 200,
theme: ‘energyblue’,
source: adapter,
sortable: true,
columns: [{
text: ‘First Name’,
datafield: ‘firstname’,
columngroup: ‘Name’,
width: 90
}, {
text: ‘Order Date’,
datafield: ‘date’,
width: 160,
cellsformat: ‘dd/MM/yyyy’
}],
});
it works great to generate the grid, the format is converted te “jj/MM/yyyy”.
but when I want to add a new row using jqxGrid(‘addrow’…), the date appears in format “jj-mm-yyyy” in the new row.
$(“#addrowbutton”).on(‘click’, function () {
var datarow = [{firstname: “new name”, date: ‘2022-09-01’}];
var commit = $(“#jqxgrid”).jqxGrid(‘addrow’, null, datarow)
});
it seams to work only when I convert date to object… but why does it work with “jj-mm-yyyy” when I generate grid first time ?
here is the fiddle :
http://jsfiddle.net/mogador/uwL7rfgx/
fabriceb