Javascript Function not able to be found

2 posts, 0 answers
  1. kevin
    kevin avatar
    2 posts
    Member since:
    Apr 2020

    Posted 24 Jun Link to this post

    The code below throws a Javascript error that the function filter can not be found. Its defined right below the control. Why can't it be found?


                            @(Html.Kendo().ComboBoxFor(m=>m.childId)
                                .HtmlAttributes(new { style = "width:100%;" })
                                .Placeholder("Select ...")
                                .DataTextField("description")
                                .DataValueField("id")
                                .DataSource(source =>
                                {
                                    source.Read(read =>
                                    {
                                        read.Action("getData", "controller1")
                                        .Type(HttpVerbs.Get)
                                        .Data("filter");
                                    })
                                    .ServerFiltering(true);
                                })

                                .AutoBind(true)
                            )           
                            <script>
                                function filter() {
                                    return {
                                        id: $("#Id").data("kendoComboBox").value()
                                    }
                                }
                            </script>
  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1995 posts

    Posted 26 Jun Link to this post

    Hi Kevin,

    Getting this exception indicates the component is initialized in a partial view. In such cases the handler must be declared before the component's initialization, so try moving the script block with the "filter" handler before the ComboBox.

    Regards,
    Ivan Danchev
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top