I'm using the React Grid component and I'm looking for a way to fire a function when double click a row.
I found a rowClick
function and I can use it now to select a row or handle an onClick event : <Grid rowClick={e => yourFunction(e)}>
.
But there is no function to handle a doubleClick event.
This is my approach, I passed a onDoubleClick()
function as props to my component, and bind it with the listener of doubleClick
on componentDidMount
for each row :
componentDidMount() {
let { onDoubleClick } = this.props;
if (onDoubleClick) {
const rows = document
.getElementsByClassName('k-widget k-grid')[0]
.getElementsByClassName('k-grid-table')[0]
.getElementsByTagName('tbody')[0]
.getElementsByTagName('tr');
for (let i = 0; i < rows.length; i++) {
rows[i].addEventListener('dblclick', () => onDoubleClick());
}
}
}
For the moment this works but I'm not able to pass the clicked row data to my function. Is there any hack to retrieve the row's data using the element ? Like this for example : onDoubleClick(kendo.data.DataSource(rows[i])) => return the json data to function.