PDA

View Full Version : Right click menu on grid



fractal
29 Jan 2007, 11:29 AM
Hello,
is it possible to have right click menu over a grid row
and this right click menu to get/work some data from the row that is clicked

tryanDLS
29 Jan 2007, 11:56 AM
Yes - read the doc. You'll have to figure out what to render - there may be examples of this already.
http://yui-ext.com/deploy/yui-ext/docs/output/YAHOO.ext.grid.Grid.html#event-rowcontextmenu

fractal
30 Jan 2007, 5:30 AM
Thanks for you answer, but i need more help to make it work

i have this grid

var grid = new YAHOO.ext.grid.Grid('grid_placeholder', {
dataModel: dataModel,
colModel: colModel,
autoSizeColumns: false,
monitorWindowResize: false,
trackMouseOver: true
}).render();

but when i try to call rowcontextmenu event it does not work

grid.rowcontextmenu = function(){
alert('boo');
}

can someone help me please

Animal
30 Jan 2007, 5:36 AM
OK, does it say "boo"?

If so, you're ready to show the Menu that you've created using the documentation: http://www.yui-ext.com/deploy/yui-ext/docs/output/YAHOO.widget.Menu.html

fractal
30 Jan 2007, 5:52 AM
no it doesn't say "boo"

thats why i am stucked
you can see what i am tryin to implement here http://www.accommodatio.biz/webcenter.php

but when i rightclick on grid element nothing is executed

you can see my js here accommodatio.biz/modules/files/files.js

Animal
30 Jan 2007, 5:56 AM
Read the manuals.

Where in the manuals does it say you can define a function called "contextmenu" in your grid, and that means the grid will call that function for you?

There is loads of help, and worked examples available for you in Jack's blog. If you read the blog entries you will learn all you need to know.

Try this: http://www.jackslocum.com/blog/2006/09/25/a-primer-on-the-grids-new-event-system/

fractal
30 Jan 2007, 6:21 AM
Hello,

thaks for your help Animal :)
it works like charm :)

from now on i will read the manuals very good :)


here is my working code


var grid = new YAHOO.ext.grid.Grid('grid_placeholder', {
dataModel: dataModel,
colModel: colModel,
autoSizeColumns: false,
monitorWindowResize: false,
trackMouseOver: true
}).render();



function myGridHandler(grid, rowIndex){
alert('Right click at row ' + rowIndex + ' !');
}

grid.addListener('rowcontextmenu', myGridHandler);

Animal
30 Jan 2007, 6:47 AM
Well done, fractal! Good to hear from someone willing to learn!