【问题标题】:Kendo date picker doesn't retain correct date剑道日期选择器不保留正确的日期
【发布时间】:2015-04-08 17:11:50
【问题描述】:

我有一个包含 2 个日期字段的 KendoGrid。两个日期都显示读取传输传递的正确初始值。但是,如果用户编辑任一日期然后单击“更新”,则更新传输会收到默认日期/时间值 {1/1/0001 12:00:00 AM}。用户更改的所有其他数据均正确,但日期均设置为 {1/1/0001 12:00:00 AM},而不是用户选择的日期。

ViewModel 代码:

public class CampaignViewModel
{       
    public int CampaignID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
}

查看代码:

    var ds = new kendo.data.DataSource({
    transport: 
        {
            read:
                {
                    url: "/Campaign/ReadCampaigns/",
                    dataType: "json"
                },
            create:
                {
                    url: "/Campaign/AddCampaign/",
                    type: "post",
                    dataType: "json"
                },
            update: 
                {
                    url: "/Campaign/UpdateCampaign",
                    type: "POST",
                    dataType: "json"
                }
        },
    batch: false,        
    schema:
    {
        model:
        {
            id: "CampaignID",
            fields:
            {
                id: { type: "number", editable: false },
                Name: { type: "string" },
                Descirption: { type: "string" },
                StartDate: { type: "date" },
                EndDate: { type: "date" }
            }
        }
    }
});

控制器代码:

    public string ReadCampaigns()
    {
        This code seems to be working fine. all dates are passed to view correctly and the dates show correctly in the kendo date pickers.
    }

    [HttpPost]
    public JsonResult AddCampaign(CampaignViewModel data)
    {
        all CampaignViewModel date fields are set to {1/1/0001 12:00:00 AM} for some reason
    }

    [HttpPost]
    public JsonResult UpdateCampaign(CampaignViewModel data)
    {
        all CampaignViewModel date fields are set to {1/1/0001 12:00:00 AM} for some reason
    }

【问题讨论】:

    标签: kendo-ui kendo-grid kendo-asp.net-mvc kendo-dataviz


    【解决方案1】:

    请通过下面给出的链接。对于您要解决的问题,它确实有几个解决方案。如果问题仍然存在,请恢复。

    Passing dates from Kendo UI to ASP.NET MVC

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多