asp.net-mvc - 与弹出编辑器一起使用以进行更新时,剑道网格客户端详细信息模板呈现问题
问题描述
使用弹出式编辑器进行更新时,Kendo 网格客户端详细信息模板无法正确呈现。我正在使用 Detail 模板显示更多列,并使用编辑器模板进行弹出编辑。起初,如果我打开详细信息模板,它可以正常工作,但如果我打开添加/更新的弹出编辑器,客户端详细信息模板就会混乱,并在编辑模式下显示列,并且布局也会受到干扰。当第二次弹出编辑器打开时,一些列样式搞砸了(例如不显示数字文本框)。
我在这里做错了什么?请指教。
起初,客户详细信息模板如下所示:
单击编辑按钮后,网格和弹出窗口如下所示:
我的代码如下:
客户详情模板:
<script id="DisplayTemplate_Bonds" type="text/kendo-tmpl">
<div>
<table style="width:auto;">
<tr>
<td style="vertical-align:top;">
<table>
<tr id='Currency'>
<td>Currency</td>
<td>Equal To</td>
<td>#=CurrencyViewModel.ID#</td>
</tr>
<tr id='Classification'>
<td>Classification</td>
<td>Equal To</td>
<td>#=ClassificationBoardViewModel.Name#</td>
</tr>
<tr id='Maturity1'>
<td>Maturity</td>
<td>Equal To</td>
<td>#=kendo.toString(Maturity1, 'n2')#</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
网格:
@(Html.Kendo().Grid<Models.Bonds_ViewModel>
()
.Name("Bonds_Grid")
.Columns(c =>
{
c.Bound(m => m.ID).Hidden();
c.Bound(m => m.FilterName)
.HtmlAttributes(new { @class = "gridDataColumns" })
.Title("Filter Name").HeaderHtmlAttributes(new { @title = "Filter Name" })
;
c.Command(p =>
{
p.Edit().Text(" ").UpdateText(" ").CancelText(" ").HtmlAttributes(new { @title = "Edit this filter" });
p.Destroy().Text(" ").HtmlAttributes(new { @title = "Delete this filter" });
});
})
.ToolBar(toolbar =>{toolbar.Create().Text("Add Filter").HtmlAttributes(new { @title = "Add" });})
.Editable(editable => editable
.Mode(Kendo.Mvc.UI.GridEditMode.PopUp)
.TemplateName("Editors/Bonds_Editor")
)
.DataSource(dataSource => dataSource
.Ajax()
.Model(m =>
{
m.Id(p => p.ID);
m.Field(p => p.CurrencyViewModel).DefaultValue(ViewData["DefaultCurrencyViewModel"] as Models.CurrencyViewModel);
m.Field(p => p.ClassificationBoardViewModel).DefaultValue(ViewData["DefaultClassificationBoardViewModel"] as Models.ClassificationBoardViewModel);
})
.Read(read => read.Action("Bonds_Read", "Phase1"))
.Create(create => create.Action("Bonds_Create", "Phase1"))
.Update(update => update.Action("Bonds_Update", "Phase1"))
.Destroy(destroy => destroy.Action("Bonds_Destroy", "Phase1"))
)
.ClientDetailTemplateId("DisplayTemplate_Bonds")
)
弹出编辑器:
@model Models.Bonds_ViewModel
@Html.HiddenFor(m => m.ID)
<table id="mainTable">
<tr>
<td>@Html.Label("Filter Name")</td>
<td>@Html.EditorFor(m => m.FilterName)</td>
<td> </td>
</tr>
<tr>
<td>@Html.Label("Currency")</td>
<td>@Html.EditorFor(m => m.CurrencyViewModel)</td>
<td> </td>
</tr>
<tr>
<td>@Html.Label("Classification")</td>
<td>@Html.EditorFor(m => m.ClassificationBoardViewModel)</td>
<td> </td>
</tr>
<tr>
<td>@Html.Label("Maturity")</td>
<td>@Html.Label("Equal To")</td>
<td>@(Html.Kendo().NumericTextBoxFor(m => m.Maturity1)
.HtmlAttributes(new { @class = "textboxFor_Styles", style = "width:90px;" })
.Format(GAM.BLL.GlobalVaribleDeclarations.DisplayFormatForDecimal)
.Spinners(true)
)
</td>
</tr>
</table>
解决方案
我在这里找到了问题。实际上,我给客户详细信息模板中的表格行提供了与控件(NumericTextboxes 和其他)ID 相同的 ID。我已经更改了行的 ID,并且一切似乎都工作正常。
例如,在客户详细信息模板中,成熟度的行 ID 是
<tr id='Maturity1'>
这与在 Popup 编辑器中自动分配给 Maturity NumerictextBox 的 id 冲突
<td>@(Html.Kendo().NumericTextBoxFor(m => m.Maturity1)
.HtmlAttributes(new { @class = "textboxFor_Styles", style = "width:90px;" })
.Format(GAM.BLL.GlobalVaribleDeclarations.DisplayFormatForDecimal)
.Spinners(true)
)
</td>
希望这对其他人有帮助。
推荐阅读
- python - matplotlib gridspec 多个图和不同类型的图
- kubernetes - 部署在 Kubernetes 上的 Kafka Producer 无法生产到在本地机器上运行的 Kafka 集群
- ios - UITableViewCell 不拦截滚动事件
- python - 如何在 Python 上执行准随机洗牌?
- swift - 如何在 Swift 中从 UIApplication 中删除窗口
- python - Click 以退出代码 2 退出是什么意思?
- pine-script - hline 在 PineScript 中无法按预期工作
- python - Python - 如何对二维数组的滑动窗口进行操作?
- sharepoint - 无法从 Microsoft App Store 获得我的应用程序批准
- regex - 获取包含“~”后跟 8 个字母数字大写字符的字符串