Hi I manage to make my problem on dropdownlist work but still i encountered another issue. this is my new code;
@foreach (var props in mymodel.GetType().GetProperties().ToList())
{
<div class="editor-line">
<label>@props.Name </label>
@(Html.Kendo().DropDownList()
.Name("ddl1_" + @props.Name)
.OptionLabel("Select")
.DataTextField("Text")
.DataValueField("Value")
.AutoBind(false)
.Events(e => e.Change("onSelect"))
.HtmlAttributes(new { style = "width: 25%" })
)
</div>
}
and here's how i populate them, sorry for the bad practice.
@foreach (var props in mymodel.GetType().GetProperties().ToList())
{
<text>
var ddl = $('#ddl1_' + "@props.Name").data("kendoDropDownList");
ddl.setDataSource(ddlSource);
</text>
}
now my problem is the .Events(e => e.Change("onSelect"))
code is not working, it makes may page fail to load because it cannot find the onSelect
function.
here is the code in javsacript
function onSelect(e) {
debugger;
if (e.item) {
var dataItem = this.dataItem(e.item);
var elementId = e.sender.element[0].id
console.log(elementId);
console.log("event :: select (" + dataItem.Text + " : " + dataItem.Value + ")");
} else {
console.log("event :: select");
}
}