【问题标题】:uncaught error: invalid template Kendu Dropdownlist未捕获的错误:无效的模板 Kendo Dropdownlist
【发布时间】:2020-01-01 02:29:30
【问题描述】:
                @*<select id="attr-code-dropdown" class="ms-TextField-field detail-input"></select>*@
                @(Html.Kendo().DropDownList()
                  .Name("AttributeCode")
                  .DataTextField("AttributeCode")
                  .DataValueField("AttributeCodeId")
                  .DataSource(source =>
                  {
                      source.Read(read =>
                      {
                          read.Action("AttributeSecurityCode_Read", "AttributeCode")
                          .Data("filterCode");
                      })
                      .ServerFiltering(true);
                  })
                .Enable(false)
                .AutoBind(false)
                .CascadeFrom("AttributeName")
                )
                <script>
                    function filterCode() {
                    return {
                        AttributeName: $("#AttributeName").val()
                        };
                    }
                </script>

我的代码出了什么问题,它给了我这个错误。

kendo.all.js:198 未捕获错误:无效模板:' 属性类型 * kendo.syncReady(function(){jQuery("#AttributeName").kendoDropDownList({"dataTextField":"AttributeTypeName","dataValueField" :"AttributeTypeId","dataSource":{"transport":{"read":{"url":"/AttributeType/AttributeTypesSecurity_Read"},"prefix":""},"schema":{"errors":"错误"}}});});

【问题讨论】:

    标签: kendo-ui kendo-asp.net-mvc


    【解决方案1】:

    如果在模板中,请尝试使用延迟脚本:

    @(Html.Kendo().DropDownList()
      .Name("AttributeCode")
      .DataTextField("AttributeCode")
      .DataValueField("AttributeCodeId")
      .DataSource(source =>
      {
          source.Read(read =>
          {
              read.Action("AttributeSecurityCode_Read", "AttributeCode")
              .Data("filterCode");
          })
          .ServerFiltering(true);
      })
      .Enable(false)
      .AutoBind(false)
      .CascadeFrom("AttributeName")
      .Deferred()  // tell kendo to do scripts below
    )
    
    <script>
    
        function filterCode() {
          return {
            AttributeName: $("#AttributeName").val()
          };
        }
    
        @Html.Kendo().DeferredScripts()
    
    </script>
    

    【讨论】:

    • 对不起史蒂夫,但那没有用。它仍然给了我同样的错误。
    • 您的读取方法正在返回所需格式的数据?这是在剑道模板中还是只是表格的一部分?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-06
    相关资源
    最近更新 更多