I'm trying to update a Kendo UI dropdownlist programmatically when pressing a button.
Main dropdown:
Goal is:
When $(".loadLayout") is clicked refresh "CreateTemplateCSS" with the "layoutTemplateID" parameter.
How can I adjust this to make it work?
Main dropdown:
@(Html.Kendo().DropDownList()
.Name(LayoutTemplate")
.OptionLabel("Templates")
.DataTextField("Text")
.DataValueField("Value")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetLayoutTemplatesDropdown", LayoutTemplate");
});
}))
<
button
class
=
"loadLayout"
type
=
"button"
>Load</
button
>
Second dropdownlist:
@(Html.Kendo().DropDownList()
.Name("CreateTemplateCSS")
.OptionLabel("Choose one")
.DataTextField("Text")
.DataValueField("Value")
.Template("<
span
class=\"glyphicon glyphicon-font\"></
span
> #:data.Text#")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetTemplateCSSTemplatesDropdown", "TemplateCSSTemplate")
.Data("filterTemplateCSSTemplates");
});
})
)
Javascript
function filterTemplateCSSTemplates() {
return {
layoutTemplateID: $("#LayoutTemplate").val()
};
}
$(".loadLayout").on("click", function (e) {
var layoutTemplateID = $("#LayoutTemplate").val();
if (layoutTemplateID) {
$("#CreateTemplateCSS").data("kendoDropDownList").refresh();
}
});
Goal is:
When $(".loadLayout") is clicked refresh "CreateTemplateCSS" with the "layoutTemplateID" parameter.
How can I adjust this to make it work?