2

我在 asp.net 核心中使用了 BeginCollectionItem。在这个集合中,我使用了剑道组合框和日期选择器,这两个数据在发布数据时都没有与模型列表绑定。任何人都知道它。

下面是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> 

当我看到$("#formid").serialize()控制台时。我找到了以下结果。

oBatchDetails%5B25e11650-70cd-4d04-9fe0-4ce0e621cbfd%5D.CheckCardNo=123456789&
CheckDate=12%2F27%2F2021&

检查日期应该在哪里oBatchDetails%5B25e11650-70cd-4d04-9fe0-4ce0e621cbfd%5D.CheckDate=12%2F27%2F2021&

但开始收集项目不能处理这个剑道日期选择器。

4

2 回答 2

2

我找到了剑道控制的解决方案。要解决此问题,需要调用渲染函数来使用剑道控件。从https://www.telerik.com/forums/datepicker-error-with-core-5-0获得参考

下面是更正后的代码,它与开始收集项目核心一起工作正常。

 @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>
于 2021-12-30T10:46:35.313 回答
-1

您可以尝试将 的名称更改为CheckDate正确的格式$(function(){})

$(function () {

            $("input[name='CheckDate']").attr("name", $("input[id$='CheckCardNo']").attr("name").replace("CheckCardNo", "CheckDate"));
        });
于 2021-12-28T03:18:14.037 回答