@Html.EJS().DropDownList("Site").PopupHeight("auto").Change("serviceList_change").Width("150px").DataSource((IEnumerable<Object>)@ViewBag.data).Text(@ViewBag.sSite).Render()
@Html.EJS().DropDownList("Cust").PopupHeight("auto").Width("150px").DataSource((IEnumerable<Object>)@ViewBag.Customer).Text(@ViewBag.sCustomer).Render()
<script>
function serviceList_change(e) {
var dropObj = document.getElementById('Site').ej2_instances[0];
var ddldist = document.getElementById('Cust').ej2_instances[0];
$.ajax({
type: "POST",
url: "/Home/FFUploadSiteselected",
data: JSON.stringify({ ssite: dropObj.value }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var text = JSON.parse(data.data).results[0].text;
ddldist.addItem({ text: text, value: text });
},
error: function (response) {
alert("fa");
// window.location.reload();
}
});
}
</script> |
@Html.EJS().DropDownList("Site").PopupHeight("auto").Change("serviceList_change").Width("150px").DataSource((IEnumerable<Object>)@ViewBag.data).Text(@ViewBag.sSite).Render()
@Html.EJS().DropDownList("Cust").PopupHeight("auto").Width("150px").DataSource((IEnumerable<Object>)@ViewBag.Customer).Text(@ViewBag.sCustomer).Render()
<script>
function serviceList_change(e) {
var dropObj = document.getElementById('Site').ej2_instances[0];
var ddldist = document.getElementById('Cust').ej2_instances[0];
$.ajax({
type: "POST",
url: "/Home/FFUploadSiteselected",
data: JSON.stringify({ ssite: dropObj.value }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
ddldist.dataSource = data;
ddldist.dataBind();
},
error: function (response) {
alert("fa");
}
});
}
</script> |
List<string> emp = new List<string>();
List<string> cust = new List<string>();
public ActionResult Index()
{
emp.Add("Andrew Fuller");
emp.Add("Anne Dodsworth");
emp.Add("Laura Callahan");
emp.Add("Nancy Davolio");
ViewBag.data = emp;
ViewBag.sSite = "Laura Callahan";
cust.Add("Robert King");
cust.Add("Nancy Devolio");
cust.Add("Michael suyama");
ViewBag.Customer = cust;
ViewBag.sCustomer = "Nancy Devolio";
return View()
}
public object FFUploadSiteselected(string ssite)
{
cust.Add("Andrew Fuller");
cust.Add("Nancy Devolio");
cust.Add("Laura Callahan");
return Json(cust);
} |