Kendo 解析日期
Kendo Parsing Date
我有自定义弹出窗口 window 并且它有效。此外,我正在从数据库中正确检索数据并绑定数据。当日期或月份超过 12 时从弹出窗口编辑这些记录时,本地主机上出现错误,例如“12/08/'2011 不是有效日期。
这是我的代码,请帮助我..
@model xxxx.Il
<h3>Customized Il</h3>
<br />
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.CustId)
@Html.HiddenFor(model => model.DegistirenKullanici)
@Html.HiddenFor(model => model.DegistirmeTarihi)
@Html.HiddenFor(model => model.KayitKullanici)
<div>
@Html.LabelFor(model => model.IlAdi)
@Html.EditorFor(model => model.IlAdi)
@Html.ValidationMessageFor(model => model.IlAdi)
</div>
<div>
@Html.LabelFor(model => model.KayitTarihi)
@Html.Kendo().DatePickerFor(model => model.KayitTarihi).Format("dd/mm/yyyy")
@Html.ValidationMessageFor(model => model.KayitTarihi)
</div>
<script>
kendo.culture("en-GB");
</script>
这是我的视图 cshtml 代码;
@using Kendo.Mvc.UI;
@model xxxxx.Il
<section id="gallery">
<h2 class="ra-well-title">Iller</h2>
<div>
<input id='txtIlId' value="" style="width:100%; text-align:center;" class="k-textbox" placeholder="Id'ye göre Arama'" />
<br>
<br />
<input id='txtIlAdi' value="" style="width:100%; text-align:center;" class="k-textbox" placeholder="Ada göre Arama'" />
<br>
<br />
</div>
<script>
kendo.culture("en-GB");
</script>
@(Html.Kendo().Grid<xxxx.Il>().Name("Iller")
.Columns(columns =>
{
columns.Bound(p => p.Id);
columns.Bound(p => p.IlAdi);
columns.Bound(p => p.DegistirenKullanici);
columns.Bound(p => p.DegistirmeTarihi);
columns.Bound(p => p.KayitKullanici);
columns.Bound(p => p.KayitTarihi).Format("{0:dd/mm/yyyy}");
columns.Command(command => { command.Edit(); }).Width(250);
})
.Pageable(pageable => pageable.Refresh(true))
.Sortable()
.AutoBind(true)
.Selectable()
.Navigatable()
.Filterable()
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("IlModel").Window(w => w.Width(450)).Window(w => w.Title("Düzenle")))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
.Read(read => read.Action("Il_Read", "Tanimlar").Data("getAdditionalData"))
.Update(update => update.Action("Il_Guncelle", "Tanimlar"))
)
)
</section>
<script type="text/javascript">
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
function onClickBul(e) {
//kendoConsole.log("event :: click (" + $(e.event.target).closest(".k-button").attr("id") + ")");
$('#Iller').data('kendoGrid').dataSource.read();
}
$('#txtIlAdi').keyup(function () {
$('#Iller').data('kendoGrid').dataSource.read();
});
function getAdditionalData(e) {
return {
//iMrpId: 2
Iladi: $('#txtIlAdi').val()
};
}
</script>
这就是我获取 kendo 日历日期的方式。
var selectedDate = kendo.toString(kendo.parseDate($("#diningCalendar").data("kendoCalendar").current()), 'MM/dd/yyyy')
使用kendo.toString(kendo.parseDate())
希望对您有所帮助。
我有自定义弹出窗口 window 并且它有效。此外,我正在从数据库中正确检索数据并绑定数据。当日期或月份超过 12 时从弹出窗口编辑这些记录时,本地主机上出现错误,例如“12/08/'2011 不是有效日期。 这是我的代码,请帮助我..
@model xxxx.Il
<h3>Customized Il</h3>
<br />
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.CustId)
@Html.HiddenFor(model => model.DegistirenKullanici)
@Html.HiddenFor(model => model.DegistirmeTarihi)
@Html.HiddenFor(model => model.KayitKullanici)
<div>
@Html.LabelFor(model => model.IlAdi)
@Html.EditorFor(model => model.IlAdi)
@Html.ValidationMessageFor(model => model.IlAdi)
</div>
<div>
@Html.LabelFor(model => model.KayitTarihi)
@Html.Kendo().DatePickerFor(model => model.KayitTarihi).Format("dd/mm/yyyy")
@Html.ValidationMessageFor(model => model.KayitTarihi)
</div>
<script>
kendo.culture("en-GB");
</script>
这是我的视图 cshtml 代码;
@using Kendo.Mvc.UI;
@model xxxxx.Il
<section id="gallery">
<h2 class="ra-well-title">Iller</h2>
<div>
<input id='txtIlId' value="" style="width:100%; text-align:center;" class="k-textbox" placeholder="Id'ye göre Arama'" />
<br>
<br />
<input id='txtIlAdi' value="" style="width:100%; text-align:center;" class="k-textbox" placeholder="Ada göre Arama'" />
<br>
<br />
</div>
<script>
kendo.culture("en-GB");
</script>
@(Html.Kendo().Grid<xxxx.Il>().Name("Iller")
.Columns(columns =>
{
columns.Bound(p => p.Id);
columns.Bound(p => p.IlAdi);
columns.Bound(p => p.DegistirenKullanici);
columns.Bound(p => p.DegistirmeTarihi);
columns.Bound(p => p.KayitKullanici);
columns.Bound(p => p.KayitTarihi).Format("{0:dd/mm/yyyy}");
columns.Command(command => { command.Edit(); }).Width(250);
})
.Pageable(pageable => pageable.Refresh(true))
.Sortable()
.AutoBind(true)
.Selectable()
.Navigatable()
.Filterable()
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("IlModel").Window(w => w.Width(450)).Window(w => w.Title("Düzenle")))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
.Read(read => read.Action("Il_Read", "Tanimlar").Data("getAdditionalData"))
.Update(update => update.Action("Il_Guncelle", "Tanimlar"))
)
)
</section>
<script type="text/javascript">
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
function onClickBul(e) {
//kendoConsole.log("event :: click (" + $(e.event.target).closest(".k-button").attr("id") + ")");
$('#Iller').data('kendoGrid').dataSource.read();
}
$('#txtIlAdi').keyup(function () {
$('#Iller').data('kendoGrid').dataSource.read();
});
function getAdditionalData(e) {
return {
//iMrpId: 2
Iladi: $('#txtIlAdi').val()
};
}
</script>
这就是我获取 kendo 日历日期的方式。
var selectedDate = kendo.toString(kendo.parseDate($("#diningCalendar").data("kendoCalendar").current()), 'MM/dd/yyyy')
使用kendo.toString(kendo.parseDate())
希望对您有所帮助。