Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141683 | Dec 27,2018 01:07 PM UTC | Jan 2,2019 08:42 AM UTC | ASP.NET MVC - EJ 2 | 8 |
![]() |
Tags: DropDownList |
@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);
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.