Kendo UI Dropdown update with parameter on button click

2 posts, 0 answers
  1. 100%
    100% avatar
    75 posts
    Member since:
    Apr 2013

    Posted 05 Nov 2015 Link to this post

    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?

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 09 Nov 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top