PDA

View Full Version : Urgent: Retain selections on 'contextmenu' event of DataView



anilcs0405
1 Feb 2010, 11:13 PM
I have a requirement in Data View, where I want to retain the previous selections on Data View (I am using drag selector plugin for selections) when a context menu is popped out.
I see that when I right click all the selections are lost and then the context menu(extjs menu) shows up.

Can anyone suggest what can be done to retain the selections?

Animal
2 Feb 2010, 12:21 AM
stop the event?

anilcs0405
2 Feb 2010, 12:35 AM
you mean the stop of contextmenu event or the deselect event? I want contextmenu event working as it is, but no deselect of already selected items should happen.

realjax
2 Feb 2010, 2:33 AM
Maybe save the selections (getSelectedNodes() ) first, and then reselect ( select() ) them on context ?

Animal
2 Feb 2010, 3:00 AM
Stop the contextmenu event.

realjax
2 Feb 2010, 3:31 AM
Stop the contextmenu event.

Of course. :)
Preventing further bubbling should be all that's needed.

anilcs0405
2 Feb 2010, 3:36 AM
When should I do that? I observe that even before my menu is opened, the selections are lost. I put some console messages in click event to see if click was captured first. But it is not the case.
I want to know which method of DataView can be overridden to avoid this.

realjax
2 Feb 2010, 3:47 AM
put a listener on the dataviews contextmenu event. It is fed (among other parameters) with the entire event, enabling you to stop it.

Animal
2 Feb 2010, 3:48 AM
If you want the context menu ONLY ON items:



listeners: {
contextmenu: function(dv, idx, node, e) {
e.stopEvent();
ctx.showAt(e.getXY());
}
}


If you want it everywhere:



listeners: {
render: function(v) {
v.getEl().on({
contextmenu: function(e) {
e.stopEvent();
ctx.showAt(e.getXY());
}
});
}
}

anilcs0405
4 Feb 2010, 2:17 AM
@realjax,
stopping the event didn't help, looks like selections are lost even before the event handler is called.

@Animal,
The first code fragment is what I am already doing.
The second code fragment can be achieved with 'containercontextmenu' and 'contextmenu'
events pointing to the same function.

What I want is retaining my previous selections when user right clicks on DataView does not matter whether he clicks on item or anywhere on the view.

I looked into the source code of the dataview, no sign of clearSelections() in 'contextmenu' or 'containercontextmenu' event handling.

Any clue in this direction will be of great help!!

Animal
4 Feb 2010, 4:27 AM
In the test page, I don't lose selection when I click context menu.