I want to disable the fields/controls in React kendo grid based on input.
For example : Based on selection of value in Full Name, I want to disable the Birth Date column
I want to disable the fields/controls in React kendo grid based on input.
For example : Based on selection of value in Full Name, I want to disable the Birth Date column
You could achieve the desired behavior by using a Custom Editor. The Custom Editor
receives the entire dataItem and is re-rendered on each change of the dateItem fields.
So you could create a custom DatePickerCell
and set the DatePicker disabled
prop based on the value of the FullName. Also set the cell
prop of the BirthDate GridColumn
to DatePickerCell
.
class DatePickerCell extends React.Component {
handleChange = (e) => {
this.props.onChange({
dataItem: this.props.dataItem,
field: this.props.field,
syntheticEvent: e.syntheticEvent,
value: e.value
});
}
render() {
const dataValue = this.props.dataItem[this.props.field];
if (!this.props.dataItem.inEdit) {
return (
<td>
{this.props.dataItem[this.props.field].toDateString()}
</td>
);
}
return (
<td>
<DatePicker
onChange={this.handleChange}
value={dataValue}
disabled={this.props.dataItem['FullName'] === 'Bradshow, John'}
/>
</td>
);
}
}
<GridColumn field="BirthDate" title="Birth Date" editor="date" format="{0:d}" cell={DatePickerCell} />