|
@{
ViewData["Title"] = "Home Page";
}
@{
var DropDownList = new Syncfusion.EJ2.DropDowns.DropDownList() { DataSource = @ViewBag.DataSource, Query = "new ej.data.Query()", AllowFiltering = true,Enabled=true, Fields = new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings() { Value = "ShipCountry", Text = "ShipCountry" },Change= "onChange" };
}
<ejs-grid id="Grid" allowPaging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Remove"></e-data-manager>
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer ID" type="string" width="120"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType='dropdownedit' edit=" new {@params = DropDownList }" ></e-grid-column>
<e-grid-column field="Freight" width="150" editType='numericedit'></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function onChange(args) {
console.log(args);
}
</script> |
|
@{
ViewData["Title"] = "Home Page";
}
@{
var DropDownList = new Syncfusion.EJ2.DropDowns.DropDownList() { DataSource = @ViewBag.DataSource, Query = "new ej.data.Query()", AllowFiltering = true,Enabled=true, Fields = new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings() { Value = "ShipCountry", Text = "ShipCountry" },Change= "onChange" };
}
<ejs-grid id="Grid" allowPaging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Remove"></e-data-manager>
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType='dropdownedit' edit=" new {@params = DropDownList }"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer ID" type="string" width="120"></e-grid-column>
<e-grid-column field="Freight" width="150" editType='numericedit'></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function onChange(args) {
var grid = document.getElementById('Grid').ej2_instances[0];
//grid id + field name
var customerIDele = document.querySelector('#' + grid.element.id + 'CustomerID');
// here we have retrieved the value of the shipcountry dropdown and applied the value on customerID field
customerIDele.value = args.value;
}
</script> |