Is there a simple way to enable a different context menu for each level of a hierarchical grid?
I only see ContextMenuOpening for the grid as a whole and don't see a way to determine which sub grid was selected which didn't involve checking column names. The templates only seem they are there to support layout.
Attached is a sample app.
Thanks,
_Dave
Figured it out:
private void Grid_MouseDown(object? sender, MouseEventArgs e) { if (Grid.ElementTree.GetElementAtPoint(e.Location) is GridDataCellElement cell && e.Button == MouseButtons.Right) { if (cell.RowInfo.ViewTemplate.Caption == "OrderInfo") { ordersContextMenu?.Show(Grid, e.Location); } else if (cell.RowInfo.ViewTemplate.Caption == "Items") { itemsContextMenu?.Show(Grid, e.Location); } } } private void Grid_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { e.Cancel = true; }
Hello, Dave,
I am really glad to hear that you managed to find a solution for achieving your requirement. Your solution for checking the caption of each grid view template before showing the context menu seems absolutely right to me. More information is available in the context menu section in our RadGridView documentation here.
If you have any other difficulties, do not hesitate to contact us.