This is a migrated thread and some comments may be shown as answers.

Javascript Function not able to be found

1 Answer 592 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
kevin
Top achievements
Rank 1
kevin asked on 24 Jun 2020, 02:03 PM
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>

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 26 Jun 2020, 07:06 AM

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.
Tags
ComboBox
Asked by
kevin
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or