|
var grid = new ej.grids.Grid({
dataSource: cascadeData,
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal' },
columns: [
{ field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 100, isPrimaryKey: true, validationRules: { required: true } },
{ field: 'CustomerID', headerText: 'Customer ID', width: 120, validationRules: { required: true, minLength: 3 } },
{
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(){
countryObj = new ej.dropdowns.DropDownList({
dataSource: country,
fields: { value: 'countryId', text: 'countryName' },
change: function(){
stateObj.enabled = true;
var tempQuery = new Query().where('countryId', 'equal', countryObj.value);
stateObj.query = tempQuery;
stateObj.text = null;
stateObj.dataBind();
},
placeholder: 'Select a country',
floatLabelType: 'Never'
});
countryObj.appendTo(countryElem);
}
}
},
{
field: 'ShipState', headerText: 'Ship State', width: 150, edit: {
create: function(){
stateElem = document.createElement('input');
return stateElem;
},
read: function(){
return stateObj.text;
},
destroy: function(){
stateObj.destroy();
},
write: function(){
stateObj = new ej.dropdowns.DropDownList({
dataSource: state,
fields: { value: 'stateId', text: 'stateName' },
enabled: false,
placeholder: 'Select a state',
floatLabelType: 'Never'
});
stateObj.appendTo(stateElem);
}
}
}
],
height: 273
}); |