EasyUI Forum

General Category => EasyUI for React => Topic started by: kifni41 on November 04, 2019, 12:55:07 AM



Title: [Solved] Right Click to show Context Menu on Datagrid Cell
Post by: kifni41 on November 04, 2019, 12:55:07 AM
Hi,

I'm trying easyui ract, previously i already use the jquery version for couple of my project.

One of the function that i still havent find a way to implement in react version, is to show context menu when user do right click on datagrid cell.

I already check the documentation, get find this event listed on GridBase component

Code:
onCellContextMenu	{row, column, originalEvent}

But when i tried to catch that event, i can only get the row & column parameter, and originalEvent parameter is always null.

I believe this originalEvent is the one that i can use to get the x & y coordinate so I can show the context menu on the area near the cell.

Anyone ever tried this?
Or is it possible to get the x&y axis from datagrid component with column & row information?



Thanks



Title: Re: Right Click to show Context Menu on Datagrid Cell
Post by: stworthy on November 04, 2019, 08:26:09 PM
Please refer to the code below:
Code:
handleCellContextMenu({row,column,originalEvent}){
originalEvent.preventDefault()
console.log(originalEvent)
}

<DataGrid data={this.state.data} style={{height:250}}
  onCellContextMenu={this.handleCellContextMenu.bind(this)}
>


Title: Re: Right Click to show Context Menu on Datagrid Cell
Post by: kifni41 on November 05, 2019, 12:12:57 AM
Thanks mate, solved

we miss the curly bracket, didn't realize it one parameter as an object, and tried with 3 parameter.


 :)