|
[Index.cshtml]
var grid = new ej.grids.Grid({
dataSource: cascadeData,
queryString: 'EmployeeID',
allowPaging: true,
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal' },
columns: [
{ field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120 },
{ field: 'ShipCity', headerText: 'Ship City', width: 120 },
{ field: 'Freight', headerText: 'Freight', width: 120 },
{
field: 'ShipCountry', headerText: 'Ship Country', width: 120, edit: {
create: function () {
countryElem = document.createElement('input');
return countryElem;
},
read: function () {
return countryObj.text;
},
destroy: function () {
countryObj.destroy();
},
write: function (args) {
countryObj = new ej.dropdowns.DropDownList({
dataSource: cascadeData,
fields: { value: 'EmployeeID', text: 'ShipCountry' },
query: new ej.data.Query().where("EmployeeID", "equal", args.rowData["EmployeeID"]), // Generate query with row EmployeeID value of parent grid basis
placeholder: 'Select a country',
floatLabelType: 'Never'
});
countryObj.appendTo(countryElem);
}
}
},
],
}) |