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

Kendo UI Dropdown update with parameter on button click

1 Answer 962 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
100%
Top achievements
Rank 1
100% asked on 05 Nov 2015, 01:58 PM
I'm trying to update a Kendo UI dropdownlist programmatically when pressing a button.

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?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 Nov 2015, 10:36 AM
Hello,

I would suggest you force the widget to re-load its data on button click. You can do that using read method of the datasource:
Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
DropDownList
Asked by
100%
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or