0

发生更新行事件时向服务器发送的日期数据格式错误。对于发送的所有数据,它以“01.01.0001 00:00:00”的形式进入服务器。发送前客户端的行日期数据是(我通过警报看到)“Sat May 05 2012 00:00:00 GMT+0300 (GTB Daylight Time)”。有什么建议吗?

在此处输入图像描述

客户端代码是:

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 });
                  }
              }
            ]
        });
4

2 回答 2

2

在 updaterow 函数中,在数据定义之前(var data = $.param(rowdata);) 我更改了日期数据,例如:

                var dateToChange = JSON.stringify(rowdata.YuklenmeTarihi);
                rowdata.YuklenmeTarihi = dateToChange.replace(/"/g, '');

然后它起作用了。replace(/"/g, '')如果您想知道,请修剪所有双引号。

于 2012-07-12T13:22:54.573 回答
0

jqxGrid 不会向服务器发送任何数据,因为它是一个客户端小部件。小部件不处理服务器更新。检查您的更新功能以及您通过 Ajax 帖子发送的数据。

于 2012-07-12T11:38:11.217 回答