Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by David on Dec 08, 2008 06:57
open dhtmlx forum
Context menus in grid with subgrids, strange behaviour

I'm using the context menu in your grid to provide deleting and some more actions.
This works fine as long as I'm only using the main grid.

But via the sub_row_grid excell every entry of the main grid can have a subgrid with several entries.
This subgrid was supposed to have another context menu, similar to the context menu of the main grid but slightly different.

In the onSubGridCreated I'll handle the initializing of the subgrid as well as the databinding. After that I'm creating a new context menu and attach it to the subgrid.

Using this approach I experienced some strange behaviour.

The context menu of the main grid works well as long no subgrid is expanded. When a subgrid is open, the context menu of the main grid will not work anymore. The context menu of the subgrid works fine. Closing the subgrid won't restore the main grid's context menu.

When I have more than one subgrid open every subgrid will have a context menu like it is expected. But the context menu of every subgrid will always to the entries of the last opened subgrid. A delete of a row in the first subgrid would fire a delete in the the same rowindex of the last opened grid, but not the entry I clicked on.

Maybe this approach is not quite correct. If so, please provide me a better way to realize stable context menus in different different grids.

Thanks.
Answer posted by Support on Dec 08, 2008 08:40
Such approach must work correctly ( while it may be more usefull to use single menu instance and just mark last active grid from onBeforeContextMenu event ) 
Working sample sent by email. 
Most probably reason of problem - usage of the same variable for all menu referencing, which may result in some tricky misuse.