How to populate Kendo.ComboBox with ajax?

281 views Asked by At

I have a Kendo.ComboBox defined in the Editor Template.

This template is referenced in the index page when Kendo.Grid is populated:

co.Bound(c => c.Name).Title("Property Name").EditorTemplateName("_MyEditor");

This is the ComboBox:

@(Html.Kendo().ComboBox()
          .Name("ReportProperty")
          .DataTextField("PropertyName")
          .DataValueField("ReportPropertyID")
          .HtmlAttributes(new { id = "idCB" })
)

There is an Event that fires in which I would like to use an Ajax call to populate this Kendo.ComboBox.

I do not wamt to use .DataSource with Action call for that, I tried and it did not work in my case, so I want to useAjax on a specific event

What is the right way to do that?

1

There are 1 answers

0
Muhammad Aftab On

try as below:

@(Html.Kendo().ComboBox()
          .Name("ReportProperty")
          .DataTextField("PropertyName")
          .DataValueField("ReportPropertyID")
          .HtmlAttributes(new { id = "idCB" })
          .DataSource(source => {
             source.Read(read =>
             {
                 read.Action("Action", "Controller");
             })
      })
)