|
countryObj = new ej.dropdowns.DropDownList({
dataSource: countryData,
fields: { value: 'ShipCountry', text: 'ShipCountry' },
change: function (args) {
// Based on dropdown value the required control is created and appended to the corresponding element
if (args.value === 'Malaysia') {
// Previous control instance stored in the global variable is destroyed
cityObj.destroy();
cityObj = new ej.dropdowns.DropDownList({
dataSource: cityData,
fields: { value: 'ShipCity', text: 'ShipCity' },
enabled: true,
placeholder: 'Select a city',
floatLabelType: 'Never'
});
cityObj.appendTo(cityElem);
var tempQuery = new ej.data.Query().where('ShipCountry', 'equal', countryObj.value);
cityObj.query = tempQuery;
cityObj.text = null;
cityObj.dataBind();
} else {
// Previous control instance stored in the global variable is destroyed
cityObj.destroy();
cityObj.enabled = true;
cityObj = new ej.inputs.TextBox({
placeholder: 'State Name',
floatLabelType: 'Never'
});
cityObj.appendTo(cityElem);
}
},
placeholder: 'Select a country',
floatLabelType: 'Never'
});
countryObj.appendTo(countryElem); |
|
function CityRead() {
return cityObj.element.value;
} |
|
function CountryWrite() {
countryObj = new ej.dropdowns.DropDownList({
dataSource: countryData,
fields: { value: 'ShipCountry', text: 'ShipCountry' },
allowFiltering: true,
//bind the filtering event handler
filtering: (e) => {
// load overall data when search key empty.
if (e.text == '') e.updateData(searchData);
else {
var query = new ej.data.Query().select(['ShipCountry']);
// The ‘contains’ operator is used for filtering the dropdown values
query = (e.text !== '') ? query.where('ShipCountry', 'contains', e.text, true) : query;
e.updateData(searchData, query);
}
},
});
} |
|
<ejs-grid id="Grid" dataSource="ViewBag.dataSource" ... >
<e-grid-columns>
<e-grid-column field="ShipCountry" headerText="ShipCountry" validationRules="@(new { required= true })" edit="@(new {create="CountryCreate",read="CountryRead",write="CountryWrite",destroy="CountryDestroy" })" width="110"> </e-grid-column>
<e-grid-column field="ShipCity" headerText="Ship City" validationRules="@(new { required= true })" edit="@(new {create="CityCreate",read="CityRead",write="CityWrite",destroy="CityDestroy" })" width="110">
</e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function CountryWrite() {
countryObj = new ej.dropdowns.DropDownList({
dataSource: countryData,
change: function (args) {
if (args.value === 'Malaysia') {
cityObj.destroy();
.
.
// Column field is set as the dynamically created edit control name
cityElem.name = "ShipCity";
cityObj.appendTo(cityElem);
.
.
} else {
cityObj.destroy();
.
.
// Column field is set as the dynamically created edit control name
cityElem.name = "ShipCity";
cityObj.appendTo(cityElem);
}
}
});
countryObj.appendTo(countryElem);
} |