4

我有一个 KendoUI Grid,它输出一些外键下拉列表和其他字段,如日期,并且由于某种原因,在呈现控件之前和之后添加了一些随机文本/字符。在下面的这个块中,<$Bw$> <$Bx$>在呈现选择列表之前作为文本输出到浏览器,后跟<$By$>.

<td role="gridcell" data-container-for="StateProvinceId">&lt;$Bw$&gt;
<!--$Bw$-->&lt;$Bx$&gt;<span style="" class="k-widget k-dropdown k-header" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="StateProvinceId_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false"><span unselectable="on" class="k-dropdown-wrap k-state-default"><span unselectable="on" class="k-input">&nbsp;</span><span unselectable="on" class="k-select"><span unselectable="on" class="k-icon k-i-arrow-s">select</span></span></span><input data-val="true" data-val-number="The field StateProvinceId must be a number." data-val-required="The StateProvinceId field is required." id="StateProvinceId" name="StateProvinceId" type="text" value="0" data-role="dropdownlist" style="display: none;" data-bind="value:StateProvinceId" class="valid"></span><script>
    jQuery(function(){jQuery("#StateProvinceId").kendoDropDownList({"dataSource":[],"dataTextField":"Text","dataValueField":"Value"});});
</script><!--$Bx$-->&lt;$By$&gt;
<!--$By$--><span class="field-validation-valid" data-valmsg-for="StateProvinceId" data-valmsg-replace="true"></span></td>

FK 编辑器模板只是默认设置。

@using Kendo.Mvc.UI

@model object
           
@(
 Html.Kendo().DropDownListFor(m => m)        
        .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
)

这发生在所有正在渲染的具有 KendoUI 编辑器模板的字段中。

错误截图

网格代码

@using Kendo.Mvc.UI
@model Data.DataModels.Person

@(Html.Kendo().Grid<Data.ViewModels.LicenseVM>()
    .Name("LicensesGrid")
    .Columns(columns =>
    {
        columns.ForeignKey(p => p.StateProvinceId, (System.Collections.IEnumerable)ViewData["StateProvinces"], "StateProvinceId", "Name")
            .Title("State");
        columns.ForeignKey(p => p.LicenseTypeId, (System.Collections.IEnumerable)ViewData["LicenseTypes"], "LicenseTypeId", "Name")
            .Title("Type");
        columns.Bound(p => p.LicenseNumber).Width(150);
        columns.Bound(p => p.ExpirationDate).Width(150);
        columns.Command(commands =>
        {
            commands.Edit(); // The "edit" command will edit and update data items
            commands.Destroy(); // The "destroy" command removes data items
        }).Title("").Width(200);
    })
    .ToolBar(toolBar =>
        {
            toolBar.Create().Text("Add License");
        })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Events(events => events.Error("error_handler"))
        .Model(model =>
        {
            model.Id(p => p.PersonLicenseId);
            model.Field(p => p.PersonId).Editable(false).DefaultValue(@Model.PersonId);
        })
        .Read(read => read.Action("_GetLicenses", "Person", new { PersonId = Model.PersonId }))
        .Create(create => create.Action("_AddLicense", "Person"))
        .Update(update => update.Action("_EditLicense", "Person"))
        .Destroy(destroy => destroy.Action("_DeleteLicense", "Person"))
    )
)

<script type="text/javascript">
    function errorHandler(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);
        }
    }
</script>
4

1 回答 1

1

这可能是 BrowserLink 添加的标记。我建议您在这种情况下禁用它。

http://www.poconosystems.com/software-development/how-to-disable-browser-link-in-visual-studio-2013/

于 2015-11-13T04:49:06.840 回答