<ej-drop-down-list id="bikeList" datasource="(IEnumerable<Bikes>)ViewBag.datasource" watermark-text="Select a bike" width="100%" change="onValueChange" >
<e-drop-down-list-fields text="text" value="value" />
</ej-drop-down-list>
<script>
var ddlObj,PreviousVal;
$(function () {
$("#bikeList_container").on("click", function () {
ddlObj = $("#bikeList").data("ejDropDownList");
PreviousVal = ddlObj.value();
});
});
function onValueChange(args) {
if (PreviousVal == 1) {
alert("Previous Value before change:" + PreviousVal);
//reset the required form fields here if the value is 1.
}
}
</script> |
<form id="form1">
<ej-drop-down-list id="bikeList" datasource="(IEnumerable<Bikes>)ViewBag.datasource" watermark-text="Select a bike" width="100%" change="onValueChange" create="onCreate">
<e-drop-down-list-fields text="text" value="value" />
</ej-drop-down-list>
<button id="set" onclick="setValue()" type="button">Set Value dynamically </button>
</form>
<script>
var ddlObj,PreviousVal;
function setValue() {
ddlObj = $("#bikeList").data("ejDropDownList");
ddlObj.setModel({ value: "1" });
}
function onCreate(args) {
PreviousVal = this.value();
}
function onValueChange(args) {
if (PreviousVal == 1) {
alert("Previous Value before change:" + PreviousVal);
//reset the required form fields here if the value is 1
}
PreviousVal = this.value();
}
</script> |