I've seen some examples for displaying a context menu and retrieving the data item of the row that was clicked, but is there a way to also determine which column of the grid was clicked when the context menu is displayed?
1 Answer, 1 is accepted
0
Anton Mironov
Telerik team
answered on 10 Nov 2023, 01:56 PM
Hello Charlie,
Thank you for the details provided.
In order to achieve the desired result, I would recommend using the following approach:
Set the filter of the ContextMenu to "td".
In the "Select" Event handler of the ContextMenu, get the instance of the Grid.
Get the current cell by using the "e.target"(use the 0 index as this will return a collection).
Use the cell in order to find its index.
Get the header name of the Grid by using the index of the current cell.
Here is an example of the Select Event handler:
var grid = $("#grid").data("kendoGrid");
var currCell = $(e.target)[0];
var currCellIndex = $(currCell).index();
var columnHeader= grid.options.columns[currCellIndex];
console.log(columnHeader);
Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the onlyREPL playground for creating, saving, running, and sharing server-side code.