jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Context menu
Tagged: grid context menu
This topic contains 8 replies, has 2 voices, and was last updated by usrimas 11 years, 2 months ago.
-
AuthorContext menu Posts
-
Hi,
I’m adding context menu to grid. It works fine . But I want to get rowid and column id from that . Now event describe “rowClick” :
$( “#” + mygrd ).on( ‘rowclick’, function( event )
{
if ( event.args.rightclick )
{
var args = event.args;
$( “#” + mygrd ).jqxGrid( ‘selectrow’, args.rowindex );
var rowid = $( “#” + mygrd ).jqxGrid( ‘getrowid’, args.rowindex );
var cell = $( “#” + mygrd ).jqxGrid( ‘getselectedcell’ );
//var celid = $( args ).own( ‘_clickedcolumn’ );
…
return false;
}
});How I can get column id , when calling context menu ?
Thanks in advance !
Hi usrimas,
You do not have selected cell in row selection mode. “getselectedcell” is for cell selection modes.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks for answer …
So how I can get column ? It’s possible with “event.args.rightclick” click ?
Hi usrimas,
event.args.rightclick returns true or false depending on whether you’ve right clicked or not. That is not related to the cell.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comPeter,
I’m asking of possibility how to get column id in such situation – right click in grid … Is this possible ?
$( "#" + mygrd ).on( 'rowclick', function( event ) { // maybe here ? if ( event.args.rightclick ) { var args = event.args; $( "#" + mygrd ).jqxGrid( 'selectrow', args.rowindex ); var rowid = $( "#" + mygrd ).jqxGrid( 'getrowid', args.rowindex ); var scrollTop = $( window ).scrollTop(); var scrollLeft = $( window ).scrollLeft(); contextMenu.jqxMenu( 'open', parseInt( event.args.originalEvent.clientX ) + 5 + scrollLeft, parseInt( event.args.originalEvent.clientY ) + 5 + scrollTop ); return false; } });
Thanks in advance !
Hi usrimas,
You can’t get the column id in “rowclick” event. You can get it in “cellclick” event in cell selection mode.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter,
Now it’s clear …
Hi,
New question about context menu. Maybe stupid question, but I’m newbie with JS, so don’t beat to strong …. Can be context menu done dynamically ? Now from sample I’m seeing that I must describe html ul/li and then can be called context menu . Mine wish is to pass array ( as in listbox for sample { label: ‘mylabel’, value: ‘myvalue’ } .. ) to function and then from array dynamically create context menu . Ts that possible ?
Thanks in advance !
Of course I must to read documentation …
Found that jqxMenu – source – do what I want .
Now another problem – can’t recognize value of clicked item .var context = [ { label: ( $app_lng == 'lt' ? "Užfiksuoti viską" : "Select all" ), value: 'select_all' }, { label: ( $app_lng == 'lt' ? "Įdėti į filtrą" : "Input to filter" ), value: 'filtras_add' }, ... var contextMenu = $( "#cont_menu" ).jqxMenu( { source: context, width: 200, height: 400, autoOpenPopup: false, mode: 'popup' } ); $( "#cont_menu" ).on( 'itemclick', function( event ) { var args = event.args; var mnp = $( args ).attr( 'value' ); if ( mnp == "naujas_irasas" ) dosome(); else if ( mnp == "perved_uzsak" ) dosome1(); ... });
How to recognise ‘value’ from clicked item in context menu ?
Thanks in advance …
-
AuthorPosts
You must be logged in to reply to this topic.