【发布时间】: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