[英]asp.net core Begin Collection Item core not working with kendo controls
I have used BeginCollectionItem in asp.net core.我在 asp.net 内核中使用了 BeginCollectionItem。 Inside this collection I have used kendo combobox and datepicker both data not bind with model list when post the data.
在这个集合中,我在发布数据时使用了剑道 combobox 和 datepicker 这两个数据都没有与 model 列表绑定。 anyone have idea about it.
任何人都知道它。
Below is the code sample for cshtml file下面是cshtml文件的代码示例
@using HtmlHelpers.BeginCollectionItemCore
@using DemoProject.Model
@model BatchDetail
<tr data-rownum="@Model.Seq">
@using (Html.BeginCollectionItem("oBatchDetails"))
{
<td>
@Html.EditorFor(model => model.CheckCardNo, new { htmlAttributes = new { @class = "form-control input-sm patientCheckCard clsAlphaNumericText", maxlength = "50", autocomplete = "off" } })
</td>
<td>
@(Html.Kendo().DatePickerFor(model => model.CheckDate).Format("MM/dd/yyyy").HtmlAttributes(new { style = "width:115px", @class = "smalldtpicker paidDate", autocomplete = "off", @type = "" }))
</td>
}
</tr>
When I see the $("#formid").serialize()
in console.当我在控制台中看到
$("#formid").serialize()
时。 I found the below result.我找到了以下结果。
oBatchDetails%5B25e11650-70cd-4d04-9fe0-4ce0e621cbfd%5D.CheckCardNo=123456789&
CheckDate=12%2F27%2F2021&
where check date should be oBatchDetails%5B25e11650-70cd-4d04-9fe0-4ce0e621cbfd%5D.CheckDate=12%2F27%2F2021&
检查日期应为
oBatchDetails%5B25e11650-70cd-4d04-9fe0-4ce0e621cbfd%5D.CheckDate=12%2F27%2F2021&
but Begin collection item not handle this kendo datepicker.但开始收集项目不能处理这个剑道日期选择器。
I found the solution for kendo control.我找到了剑道控制的解决方案。 to resolve this issue need to call render function to work with kendo controls.
要解决此问题,需要调用渲染 function 以使用剑道控件。 Got the reference from https://www.telerik.com/forums/datepicker-error-with-core-5-0
从https://www.telerik.com/forums/datepicker-error-with-core-5-0获得参考
below is the corrected code and it is workin fine with begin collection item core.下面是更正后的代码,它可以与开始收集项目核心一起正常工作。
@using HtmlHelpers.BeginCollectionItemCore
@using DemoProject.Model
@model BatchDetail
<tr data-rownum="@Model.Seq">
@using (Html.BeginCollectionItem("oBatchDetails"))
{
<td>
@Html.EditorFor(model => model.CheckCardNo, new { htmlAttributes = new { @class = "form-control input-sm patientCheckCard clsAlphaNumericText", maxlength = "50", autocomplete = "off" } })
</td>
<td>
@{
Html.Kendo().DatePickerFor(model => model.CheckDate).Format("MM/dd/yyyy").HtmlAttributes(new { style = "width:115px", @class = "smalldtpicker paidDate", autocomplete = "off", @type = "" }).Render();
}
</td>
}
</tr>
You can try to change the name of CheckDate
to the correct format in $(function(){})
:您可以尝试将
CheckDate
的名称更改为$(function(){})
中的正确格式:
$(function () {
$("input[name='CheckDate']").attr("name", $("input[id$='CheckCardNo']").attr("name").replace("CheckCardNo", "CheckDate"));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.