ReferenceError: не определен filterProducts, который является функцией Javascript

0

Я хочу использовать эту функцию Javascript "filterProduct". Я хочу использовать его для раскрытия кендо как:

@(Html.Kendo().DropDownList()
    .Name("ReferenceValue") //The name of the dropdownlist is mandatory. It specifies the "id" attribute of the widget.
    .DataTextField("ValidValue") //Specifies which property of the Product to be used by the dropdownlist as a text.
    .DataValueField("ReferenceValidValueID") //Specifies which property of the Product to be used by the dropdownlist as a value.
    .BindTo(Model)
            .DataSource(source =>
            {
                source.Read(read =>
                {
                    read.Action("GetReferenceValidValue", "GetData").Data("filterProducts"); //Set the Action and Controller name
                })
                .ServerFiltering(true); //If true the DataSource will not filter the data on the client.
            })
    .SelectedIndex(0) //Select first item.
)

<script>
    function filterProducts() {
        return {
            categories: $("#categories").val()
        };
    }
</script>

Но когда я нажимаю на раскрывающийся список, тогда одно исключение вызывается как,

ReferenceError: filterProducts is not defined

Пожалуйста, помогите мне в этом, как я могу использовать функцию Javascript.

Теги:
kendo-ui

1 ответ

1
Лучший ответ

Вы можете попробовать переместить тег сценария перед объявлением DropDownList.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню