We are using Cascading Dropdown. It's working properly, when in User starts editing a particular row. We want the ability to Edit any column based upon which the next column will get populated.
Normal flow is Division-->Department-->Category
In the above without selecting the division again, grid is not allowing to edit department and category. But we want to allow user to edit department or category.
If user is editing the Department based upon that value Category will get updated.
App.component.ts
this.countryParams = {
create: () => {
this.countryElem = document.createElement('input');
return this.countryElem;
},
read: () => {
return this.countryObj.text;
},
destroy: () => {
this.countryObj.destroy();
},
write: args => {
this.countryObj = new DropDownList({
dataSource: this.country,
text: args.rowData[args.column.field],
fields: { value: 'countryId', text: 'countryName' },
change: () => {
this.stateObj.enabled = true;
let tempQuery: Query = new Query().where(
'countryId',
'equal',
this.countryObj.value
);
this.stateObj.query = tempQuery;
this.stateObj.text = null;
this.stateObj.dataBind();
},
placeholder: 'Select a country',
floatLabelType: 'Never'
});
this.countryObj.appendTo(this.countryElem);
}
};
this.customerParams = {
create: () => {
this.customerElem = document.createElement('input');
return this.customerElem;
},
read: () => {
return this.customerObj.text;
},
destroy: () => {
this.customerObj.destroy();
},
write: args => {
this.customerObj = new DropDownList({
dataSource: this.Customer,
text: args.rowData[args.column.field],
fields: { value: 'CustomerId', text: 'CustomerName' },
change: () => {
this.stateObj.enabled = true;
let tempQuery: Query = new Query().where(
'CustomerId',
'equal',
this.customerObj.value
);
this.stateObj.query = tempQuery;
this.stateObj.text = null;
this.stateObj.dataBind();
},
placeholder: 'Select a country',
floatLabelType: 'Never'
});
this.customerObj.appendTo(this.customerElem);
}
};
this.stateParams = {
create: () => {
this.stateElem = document.createElement('input');
return this.stateElem;
},
read: () => {
return this.stateObj.text;
},
destroy: () => {
this.stateObj.destroy();
},
write: args => {
debugger;
this.stateObj = new DropDownList({
dataSource: this.state,
text: args.rowData[args.column.field],
fields: { value: 'stateId', text: 'stateName' },
enabled: false,
placeholder: 'Select a state',
floatLabelType: 'Never'
});
this.stateObj.appendTo(this.stateElem);
}
};
}
|
In the current implementation the second dropdown(Ship State Dropdown) is not editable in when User is trying to edit.
We want it work normally when user is adding an item for the first time.
But when in edit mode it should allow User to edit ship state(second dropdown).
If user changes Ship Country it should then make the Ship State blank.
[app.component.ts]
this.stateParams = { create: () => {
this.stateElem = document.createElement('input');
return this.stateElem;
},
read: () => {
return this.stateObj.text;
},
destroy: () => {
this.stateObj.destroy();
},
write: args => {
var bool;
if (args.requestType == 'add') {
bool = false;
} else {
bool = true; // enable the ShipState dropdown while editing.
var tQuery = new Query().where('countryId', 'equal', this.countryObj.value); //set the data for the ShipState dropdown based on the ShipCountry value
}
this.stateObj = new DropDownList({
dataSource: this.state,
query: tQuery,
text: args.rowData[args.column.field],
fields: { value: 'stateId', text: 'stateName' },
enabled: bool,
placeholder: 'Select a state',
floatLabelType: 'Never'
});
this.stateObj.appendTo(this.stateElem);
}
}; |