<div id="drodpown">
@Html.EJS().DropDownList("games").Width("300px").Change("changeHandler").Placeholder("Select a game").PopupHeight("200px").PopupWidth("300px").DataSource((IEnumerable<object>)ViewBag.data).Render()
</div>
<div id="textbox">
@Html.EJS().TextBox("firstname").Value("company").Placeholder("First Name").Render()
</div>
<div id="date">
@Html.EJS().DatePicker("datepicker").Value(ViewBag.value).Render()
</div>
<script type="text/javascript">
function changeHandler(args) {
var textObj = document.getElementById('firstname').ej2_instances[0];
var dateObj = document.getElementById('datepicker').ej2_instances[0];
if (args.value == "Badminton") {
textObj.value = "Syncfusion";
dateObj.value = new Date("12/10/2020");
}
if (args.value == "Basketball") {
textObj.value = "Abc";
dateObj.value = new Date("11/5/2020");
}
if (args.value == "Gymnastics") {
textObj.value = "cfv";
dateObj.value = new Date("03/04/2020");
}
}
</script>
|
<script type="text/javascript">
function changeHandler(args) {
var textObj = document.getElementById('firstname').ej2_instances[0];
var dateObj = document.getElementById('datepicker').ej2_instances[0];
if (args.value == "Badminton") {
textObj.value = '@Html.Raw(ViewBag.text1)';
dateObj.value = '@Html.Raw(ViewBag.date1)';
}
if (args.value == "Basketball") {
textObj.value = '@Html.Raw(ViewBag.text2)';
dateObj.value = '@Html.Raw(ViewBag.date2)';
}
if (args.value == "Gymnastics") {
textObj.value = '@Html.Raw(ViewBag.text3)';
dateObj.value = '@Html.Raw(ViewBag.date3)';
}
}
</script>
|
Hello Daniel,Good day to you.Based on your requirement we have modified the sample ‘While dynamically change DropDownList value, update value of datepicker and textbox from controller’. Please find the code example and sample for your reference.[Index.cshtml]
<script type="text/javascript">function changeHandler(args) {var textObj = document.getElementById('firstname').ej2_instances[0];var dateObj = document.getElementById('datepicker').ej2_instances[0];if (args.value == "Badminton") {textObj.value = '@Html.Raw(ViewBag.text1)';dateObj.value = '@Html.Raw(ViewBag.date1)';}if (args.value == "Basketball") {textObj.value = '@Html.Raw(ViewBag.text2)';dateObj.value = '@Html.Raw(ViewBag.date2)';}if (args.value == "Gymnastics") {textObj.value = '@Html.Raw(ViewBag.text3)';dateObj.value = '@Html.Raw(ViewBag.date3)';}}script>Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication1-515425102
Kindly check with the above provided sample. If you need further assistances, please get back us.Regards,Ponmani M
<div id="drodpown">
@Html.EJS().DropDownList("games").Width("300px").Change("changeHandler").Placeholder("Select a game").PopupHeight("200px").PopupWidth("300px").DataSource((IEnumerable<object>)ViewBag.data).Render()
</div>
<div id="textbox" style="width:100px">
@Html.EJS().TextBox("PONumber").Value("company").Placeholder("First Name").Render()
</div>
@Html.EJS().Grid("Flat").DataSource((IEnumerable<object>)ViewBag.DataSource1).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("90").Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("70").Add();
}).AllowPaging().Render()
<script type="text/javascript">
function changeHandler(args) {
var textObj = document.getElementById('PONumber').ej2_instances[0];
// get the grid instances by element ID
var gridObj = document.getElementById("Flat").ej2_instances[0];
if (args.value == "Badminton" || args.value == "Basketball" || args.value == "Gymnastics") {
// create the ajax
var ajax = new ej.base.Ajax({
url: "/Home/GridData1",
type: "POST",
contentType: "application/json"
});
// send ajax post to the server & receive the data returned from the server
ajax.send().then(function (data) {
textObj.value = '@Html.Raw(ViewBag.text1)';
// convert the JSON string into JSON object
var data = JSON.parse(data);
console.log(data.result);
// bind the JSON object to the grid
gridObj.dataSource = data.result;
}).catch(function (xhr) {
console.log(xhr);
});
}
}
</script>
|
if (dm.where != null)
{
Data = (from cust in Data
select cust).ToList();
}
if (dm.take != 0)
Data = Data.Take(dm.take).ToList();
return Json(Data);
}
|