telerik - 需要在弹出编辑器模板中对 DropDownFor 的读取操作传递模型值
问题描述
我有一个 Telerik 网格 (MVC),在网格行上配置了一个弹出编辑器。在编辑器模板中,除了显示网格行值的文本框外,我还有一个 DropDownFor 列表。这一切都有效。
DropDownFor 有一个读取操作,我需要将模型值传递给控制器以设置所选值。 无法识别模型值。
这是 DropDownFor:
@(Html.Kendo().DropDownListFor(m => m.OuterDiameter)
.Name("OuterDiameter")
.DataValueField("Text")
.DataTextField("Value")
.DataSource(ds =>
{
ds.Read(read =>
{
read.Action("GetPipeOD", "Materials", new { od = m.OuterDiameter });
});
})
.HtmlAttributes(new { style="width:100px"})
)
解决方案
您可以使用 JavaScript 函数传递 adicional 参数。
@(Html.Kendo().DropDownListFor(m => m.OuterDiameter)
.Name("OuterDiameter")
.DataValueField("Text")
.DataTextField("Value")
.DataSource(ds =>
{
ds.Read(read =>
{
read.Action("GetPipeOD", "Materials").Data("getParameter");
});
})
.HtmlAttributes(new { style="width:100px"})
)
<script>
function getParameter() {
return od: '@Model.Parameter'
//Or what do you need...
}
</script>
推荐阅读
- google-cloud-platform - Google Speech to Text 域适配
- python - 使用 Beautiful Soup (Python) 从表中提取特定值
- google-earth-engine - 在谷歌地球引擎中计算高程等级的损失面积
- c - 如何在 C 程序中从终端读取输入
- node.js - Discord rest API:从公会中踢出成员
- git - 如果文件大小匹配,是否可以将 git 配置为忽略 .frx 文件中的差异?
- django - Django REST 框架:SearchFilter 不适用于搜索栏中的 2 个或更多值,如果它们来自同一字段
- flutter - Flutter:无法对齐底部的文本字段
- java - beans.xml 拦截器无效,发现模式“注释”
- flutter - 包装类不包装小部件