Kendo ui grid date field,更新前一天

时间:2015-04-22 10:47:38

标签: kendo-ui kendo-grid kendo-mobile

我已经看到this关于“Wannes”的评论,这正是我发生的事情,但我不知道如何解决它,因为我不明白这个问题。我所拥有的是一个使用CRUD的简单网格。

网格是一个客户端表,无论何时想要添加新客户端,他都会点击新按钮并显示一个弹出窗口。在这个popover中有很多字段,其中两个是:

DataCriacao (创建客户端的日期)

DataUpdate (客户端更新的日期)

这是我的网格初始化代码:

var dataSource  = new kendo.data.DataSource({
        transport: 
        {
          read:  
            {
              url: "data/clientes.php",        
            },

          update: 
            {
              url: "data/clientes.php?type=update",
              type:"POST",
              complete: function (e) 
              {
                $("#gridClientes").data("kendoGrid").dataSource.read();
              } 
            },
          destroy: 
            {
              url: "data/clientes.php?type=destroy",
              type: "POST"
            },
          create: 
            {
              url: "data/clientes.php?type=create",
              type: "POST",
              complete: function (e) 
              {
                $("#gridClientes").data("kendoGrid").dataSource.read();
              }
            },
            parameterMap: function(options, operation) 
            {
                if (operation !== "read" && options.models) 
                {
                    return {models: kendo.stringify(options.models)};
                }
            }                      
        },
        error:function(e)
        {
          console.log(e);
        },
        batch: true,
        pageSize: 8,
        schema: 
        {
            data: "data",
            total: function(response) 
            {
              return $(response.data).length;
            },
            model: 
            {
              id: "idCliente",
              fields: 
              {
                **(other fields here)**
                NomeUtilizadorCriador: {editable: false,validation: { required: false } },
                DataCriacao: {type:"date",   editable: false},
                NomeUtilizadorUpdate: {editable: false, validation: { required: false } },
                DataUpdate: {type:"date",   editable: false},
              }
            }
        }
      });
      $("#gridClientes").kendoGrid({
          dataSource: dataSource,            
          pageable: 
          {
           messages: 
           {
            display: "{0} - {1} / {2} items", 
            empty: "0 items",
            page: "Page",
            of: "of {0}", //{0} is total amount of pages
            itemsPerPage: "items per page",
            first: "Go to the first page",
            previous: "Go to the previous page",
            next: "Go to the next page",
            last: "Go to the last page",
            refresh: "Refresh"
            }
          },
          serverPaging: true,
          height: 550,
          toolbar:[{name: "create",text: $varGridQuartosBtnNovoPT},{name: "close",text: "X"}],
          columns: [  
                  **(other fields here)**
                  { field: "NomeUtilizadorCriador", title: "Criado por", hidden: true},
                  { field: "DataCriacao", title: "Criado em",format:"{0:yyyy-MM-dd}", hidden: true, width: "10px"},
                  { field: "NomeUtilizadorUpdate", title: "Atualizado por", hidden: true},
                  { field: "DataUpdate", title: "Atualizado em",format:"{0:yyyy-MM-dd}", hidden: true, width: "10px"},
                  {command:[{ text: "Detalhes", click: showDetails },{ name: "edit",text:
                  {edit:$varGridQuartosBtnEditarPT,update:$varGridQuartosBtnActualizarPT,cancel:$varGridQuartosBtnCancelarPT}},
                  { name: "destroy",text:$varGridQuartosBtnApagarPT }],title:" ",width: "30px"}],

          editable: {
            mode:"popup",

            template:kendo.template($("#popupGridClientes").html())

          }

因此,例如,如果我想今天创建一个新客户端,这就是这两个字段中出现的内容:

DataCriacao:2015年4月22日星期三10:46:02 GMT + 0100(WEST)(创建日期)

DataUpdate:Wed Apr 22 2015 10:46:02 GMT + 0100(WEST)(更新日期)

现在,如果我想更新客户端信息,则会出现问题:

DataUpdate:2015年4月22日星期三00:00:00 GMT + 0100(WEST)(更新日期)

这两个字段在我的数据库中是DATE类型。我不知道该怎么办,因为我不明白从哪里开始,this有帮助吗?

1 个答案:

答案 0 :(得分:1)

我不知道我是否理解正确,但正如您所说,您以DATE格式将数据存储在数据库中。这就是为什么时间部分在你的例子中为零。 检查数据库中的数据。它应该没有时间。 问题出现在你的后端/数据库端。