function onPopupOpen(args) {
if (args.type === 'Editor') {
// Create required custom elements in initial time
if (!args.element.querySelector('.custom-field-row')) {
var row = new ej.base.createElement('div', { className: 'custom-field-row' });
var formElement = args.element.querySelector('.e-schedule-form');
formElement.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row'));
var container = new ej.base.createElement('div', { className: 'custom-field-container' });
var inputEle = new ej.base.createElement('input', {
className: 'e-field', id: 'state', attrs: { name: 'State' }
});
container.appendChild(inputEle);
row.appendChild(container);
var drowDownList = new ej.dropdowns.DropDownList({
dataSource: [
{ StateName: "New York", CountryId: "1", StateId: "101" },
{ StateName: "Queensland", CountryId: "2", StateId: "104" },
{ StateName: "Tasmania ", CountryId: "2", StateId: "105" },
{ StateName: "Victoria", CountryId: "2", StateId: "106" },
{ StateName: "Virginia ", CountryId: "1", StateId: "102" },
{ StateName: "Washington", CountryId: "1", StateId: "103" }
],
change: function () {
var cityObj = args.element.querySelector('#city').ej2_instances[0];
var stateObj = args.element.querySelector('#state').ej2_instances[0];
// enable the city DropDownList
cityObj.enabled = true;
// Query the data source based on state DropDownList selected value
var tempQuery1 = new ej.data.Query().where('StateId', 'equal', stateObj.value);
// set the framed query based on selected value in city DropDownList.
cityObj.query = tempQuery1;
//clear the existing selection
cityObj.text = null;
// bind the property change to city DropDownList
cityObj.dataBind();
},
fields: { value: 'StateId', text: 'StateName' },
value: args.EventType,
floatLabelType: 'Always', placeholder: 'State'
});
drowDownList.appendTo(inputEle);
inputEle.setAttribute('name', 'State');
}
if (!args.element.querySelector('.custom-field-row1')) {
var row = new ej.base.createElement('div', { className: 'custom-field-row1' });
var formElement = args.element.querySelector('.e-schedule-form');
formElement.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row'));
var container = new ej.base.createElement('div', { className: 'custom-field-container' });
var inputEle = new ej.base.createElement('input', {
className: 'e-field', id: 'city', attrs: { name: 'City' }
});
container.appendChild(inputEle);
row.appendChild(container);
var drowDownList = new ej.dropdowns.DropDownList({
dataSource: [
{ CityName: "Aberdeen", StateId: "103", CityId: '207' },
{ CityName: "Alexandria", StateId: "102", CityId: '204' },
{ CityName: "Albany", StateId: "101", CityId: '201' },
{ CityName: "Beacon ", StateId: "101", CityId: '202' },
{ CityName: "Brisbane ", StateId: "104", CityId: '211' },
{ CityName: "Cairns", StateId: "104", CityId: '212' },
{ CityName: "Colville ", StateId: "103", CityId: '208' },
{ CityName: "Devonport", StateId: "105", CityId: '215' },
{ CityName: "Emporia", StateId: "102", CityId: '206' },
{ CityName: "Geelong", StateId: "106", CityId: '218' },
{ CityName: "Hampton ", StateId: "102", CityId: '205' },
{ CityName: "Healesville ", StateId: "106", CityId: '217' },
{ CityName: "Hobart", StateId: "105", CityId: '213' },
{ CityName: "Launceston ", StateId: "105", CityId: '214' },
{ CityName: "Lockport", StateId: "101", CityId: '203' },
{ CityName: "Melbourne", StateId: "106", CityId: '216' },
{ CityName: "Pasco", StateId: "103", CityId: '209' },
{ CityName: "Townsville", StateId: "104", CityId: '210' }
],
fields: { text: 'CityName', value: 'CityId' },
value: args.EventType,
floatLabelType: 'Always', placeholder: 'City'
});
drowDownList.appendTo(inputEle);
inputEle.setAttribute('name', 'City');
}
} |