jQWidgets Forums

jQuery UI Widgets Forums Grid Context menu

This topic contains 8 replies, has 2 voices, and was last updated by  usrimas 11 years, 2 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Context menu Posts
  • Context menu #51087

    usrimas
    Participant

    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 !

    Context menu #51116

    Peter Stoev
    Keymaster

    Hi usrimas,

    You do not have selected cell in row selection mode. “getselectedcell” is for cell selection modes.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Context menu #51138

    usrimas
    Participant

    Thanks for answer …

    So how I can get column ? It’s possible with “event.args.rightclick” click ?

    Context menu #51140

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Context menu #51143

    usrimas
    Participant

    Peter,

    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 !

    Context menu #51158

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Context menu #51164

    usrimas
    Participant

    Thanks Peter,

    Now it’s clear … 🙂

    Context menu #51231

    usrimas
    Participant

    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 !

    Context menu #51270

    usrimas
    Participant

    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 …

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.