|
// “ShipCountry” dropdown cell edit template’s write method
function CountryWrite() {
countryObj = new ej.dropdowns.DropDownList({
dataSource: countryData,
fields: { value: 'countryId', text: 'countryName' },
// “ShipCountry” dropdown’s change event handler
change: function () {
// The “ShipCity” edit dropdown is enabled(initially disabled using this property)
cityObj.enabled = true;
// A query is created based on the “ShipCountry’s” value so that only same value fields in the “ShipCity” dropdown is present in the data source
var tempQuery = new ej.data.Query().where('countryId', 'equal', countryObj.value);
// The created query is assigned to the “ShipCity” edit dropdown’s query property
cityObj.query = tempQuery;
cityObj.text = null;
cityObj.dataBind();
},
placeholder: 'Select a country',
floatLabelType: 'Never'
});
countryObj.appendTo(countryElem);
} |
|
var USCityData = @Html.Raw(Json.Serialize(ViewBag.USCityData));
var AusCityData = @Html.Raw(Json.Serialize(ViewBag.AusCityData));
// “ShipCountry” dropdown cell edit template’s write method
function CountryWrite() {
countryObj = new ej.dropdowns.DropDownList({
dataSource: countryData,
fields: { value: 'countryId', text: 'countryName' },
// “ShipCountry” dropdown’s change event handler
change: function () {
// The “ShipCity” edit dropdown is enabled(initially disabled using this property)
cityObj.enabled = true;
// The “ShipCity” edit dropdown data is assigned based on the current selected dropdown value
cityObj.dataSource = (countryObj.value === 1) ? USCityData : AusCityData;
// The edit dropdown data is refreshed
cityObj.dataBind();
}
});
countryObj.appendTo(countryElem);
} |
|
function writeLocation(args) {
// create a dropdown control
locationObject = new ej.dropdowns.DropDownList({
dataSource: locationData,
placeholder: args.column.headerText,
floatLabelType: "Always",
fields: { text: "description", value: "locationID" },
change: function () {
referenceObject.enabled = true;
// The referenceObject dropdown’s data and fields are modified based on the locationObject dropdown selected value
if (locationObject.value === 2) {
referenceObject.dataSource = substationData;
referenceObject.fields = { value: 'substationID', text: 'name' };
} else {
referenceObject.dataSource = truckData;
referenceObject.fields = { value: 'truckID', text: 'description' };
}
referenceObject.dataBind();
}
});
//render the component
locationObject.appendTo(args.element);
} |