0
                @*<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>

What is wrong with my code it gives me this error.

kendo.all.js:198 Uncaught Error: Invalid template:' Attribute Type * kendo.syncReady(function(){jQuery("#AttributeName").kendoDropDownList({"dataTextField":"AttributeTypeName","dataValueField":"AttributeTypeId","dataSource":{"transport":{"read":{"url":"/AttributeType/AttributeTypesSecurity_Read"},"prefix":""},"schema":{"errors":"Errors"}}});});

1 Answers1

0

If that is within a template, try using deferred scripts:

@(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>
Steve Greene
  • 12,029
  • 1
  • 33
  • 54