initially loading the localdatasource while changing dropdown loading server side data in kendo

StackOverflow https://stackoverflow.com/questions/22980595

  •  01-07-2023
  •  | 
  •  

Frage

I have a small requirement i.e initially i want to load the Local DataSource to DropDownList. while changing DropDownlist i want to load Server Side DataSource. If it is possible to do.

War es hilfreich?

Lösung

try this,

<div id='parentDiv'><div id='dropDown'></div></div>

<script type='text/javascript'>

 $(document).ready(function() {
                var data = [
                    { text: "Black", value: "1" },
                    { text: "Orange", value: "2" },
                    { text: "Grey", value: "3" }
                ];

                // create DropDownList from input HTML element
                $("#dropDown").kendoDropDownList({
                    dataTextField: "text",
                    dataValueField: "value",
                    dataSource: data,
                    index: 0,
                    change: onChange
                });

 function onChange(e)
 {

    var serachActionUrl="url";
    $.ajax({
        url: serachActionUrl,
        type: "POST",
        data: { Id: Id},
        traditional: true,
        success: function (result) {
         $('#dropDown').remove();
         $("<div id='dropDown'/>").appendTo('#parentDiv').kendoDropDownList({
              dataTextField: "text",
              dataValueField: "value",
              dataSource: result,
              index: 0,
              change: onChange
          });
        }
    });


</script>

from the server sidesend the json data

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top