首页 > 解决方案 > 需要在弹出编辑器模板中对 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"})

 )

标签: telerik

解决方案


您可以使用 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>

推荐阅读