I'm starting to worry a little that I paid a lot of money for something that may not work. The comments on this forum about MVC are scaring me.
What I want to do is to post to my controller when someone changes the selected item on a kendo dropdown list. All of the examples show this as how to process the change event:
function change(e) {
// handle change event
};
I've got this in my view:
The control gets populated with all the items and when I click on an item the value in the control changes. The event fires - I can hit the breakpoint that I set in my event handler but I've tried everything I can think of to find out what the new selected value is, but everything shows up as undefined.
Here are just some of the things I've tried:
Nothing works. I just don't seem to be able to get the selected value and I can't find any example of how to "handle" the event. I cannot believe that it isn't something really stupid that I'm doing.
What I want to do is to post to my controller when someone changes the selected item on a kendo dropdown list. All of the examples show this as how to process the change event:
function change(e) {
// handle change event
};
I've got this in my view:
@(Html.Kendo().DropDownList() .Name("StatesDDL") .DataTextField("StateName") .DataValueField("StateID") .DataSource(s => { s.Read(r => { r.Action("GetStates", "Donation"); }); }) .SelectedIndex(selectedState) .Height(300) //.HtmlAttributes(new { id = "StateDDL" }) .Events(e => { e.Change("change")/*.Select("select")*/; }))The control gets populated with all the items and when I click on an item the value in the control changes. The event fires - I can hit the breakpoint that I set in my event handler but I've tried everything I can think of to find out what the new selected value is, but everything shows up as undefined.
Here are just some of the things I've tried:
function change(e) { var x = $('StatesDDL option:selected').text(); var y = $('StateDDL option:selected').val(); var z = $("StatesDDL").val("DataTextField").val("StateName"); var z1 = $("StatesDDL").data("DataTextField", "StateName").val(); var z2 = $("StatesDDL").data("DataValueField", "StateID").val(); var z3 = $('StatesDDL').data(); var z4 = $(this).text(); alert("Changed"); // how to get value that was selected? // how to get the changed value? // I want to then use ajax to sent that up to my controller};Nothing works. I just don't seem to be able to get the selected value and I can't find any example of how to "handle" the event. I cannot believe that it isn't something really stupid that I'm doing.