发生更新行事件时发送到服务器的日期数据格式错误。对于发送的所有数据,它作为“01.01.0001 00:00:00”进入服务器。在发送之前客户端的行日期数据是(我通过警报看到)“星期六05 05 2012 00:00:00 GMT + 0300(GTB日光时间)”。有什么建议吗?
客户端代码是:
var gridSource = {
datatype: "json",
datafields: [{ name: 'KargoId' }, { name: 'Ad' }, { name: 'Soyad' },
{ name: 'YuklenmeTarihi', type: 'date' }, { name: 'Adet' }, { name: 'Fiyat'}],
url: 'BindGrid',
updaterow: function (rowid, rowdata) {
if (selectedUrunId != undefined && selectedUrunId != -1) {
rowdata.UrunId = selectedUrunId;
selectedUrunId = -1;
}
alert(rowdata.YuklenmeTarihi);
var data = $.param(rowdata);
//alert(data);
$.ajax({
dataType: 'json',
url: 'UpdateEditGrid',
data: data,
success: function (data, status, xhr) {
gridDataAdapter.dataBind();
/*if (data.Success == false)
alert(JSON.stringify(data));*/
/*if (data.Success == true && gridDataAdapter != undefined)
gridDataAdapter.dataBind();*/
},
error: function (xhr, status, error) {
alert(JSON.stringify(xhr));
}
});
}
};
var gridDataAdapter = new $.jqx.dataAdapter(gridSource, {
downloadComplete: function (data, status, xhr) { },
loadComplete: function (data) { },
loadError: function (xhr, status, error) { alert(JSON.stringify(xhr)); }
});
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 670,
source: gridDataAdapter,
editable: true,
theme: theme,
selectionmode: 'singlecell',
columns: [
{ text: '#', datafield: 'KargoId', width: 40 },
{ text: 'Ad', columntype: 'textbox', datafield: 'Ad', width: 90 },
{ text: 'Soyad', datafield: 'Soyad', columntype: 'textbox', width: 90 },
{ text: 'YuklenmeTarihi', datafield: 'YuklenmeTarihi', columntype: 'datetimeinput', width: 90, cellsalign: 'right', cellsformat: 'd',
validation: function (cell, value) {
var year = value.getFullYear();
if (year >= 2013) {
return { result: false, message: "Yükleme zamanı 1/1/2013 tarihinden önce olmalı!" };
}
return true;
}
},
{ text: 'Adet', datafield: 'Adet', width: 70, cellsalign: 'right', columntype: 'numberinput',
validation: function (cell, value) {
if (value < 1 || value > 15) {
return { result: false, message: "Adet 1-15 aralığında olmalı!" };
}
return true;
},
initeditor: function (row, cellvalue, editor) {
editor.jqxNumberInput({ decimalDigits: 0, digits: 3 });
}
},
{ text: 'Fiyat', datafield: 'Fiyat', width: 65, cellsalign: 'right', cellsformat: 'c2', columntype: 'numberinput',
validation: function (cell, value) {
if (value < 0 || value > 15) {
return { result: false, message: "Fiyat 0-15 aralığında olmalı!" };
}
return true;
},
initeditor: function (row, cellvalue, editor) {
editor.jqxNumberInput({ digits: 3 });
}
}
]
});
答案 0 :(得分:2)
在updaterow函数中,在数据定义之前(var data = $ .param(rowdata);)我更改了日期数据,如:
var dateToChange = JSON.stringify(rowdata.YuklenmeTarihi);
rowdata.YuklenmeTarihi = dateToChange.replace(/"/g, '');
然后它奏效了。如果你想知道,replace(/"/g, '')
修剪所有双引号。
答案 1 :(得分:0)
jqxGrid不会向服务器发送任何数据,因为它是客户端小部件。小部件不处理服务器更新。检查您的更新功能以及您通过Ajax帖子发送的数据。