Hi.... @allan, i am trying to work with datatable key arrow navigation, datatable is a child table,

Hi.... @allan, i am trying to work with datatable key arrow navigation, datatable is a child table,

PreethipreethuPreethipreethu Posts: 4Questions: 1Answers: 0

but i am unable to use scrolling with key arrows, can you help to come out from this problem.

Answers

  • allanallan Posts: 64,756Questions: 1Answers: 10,716 Site admin

    Can you give me a link to a test case showing the issue so I can see what you are working with.

    Thanks,
    Allan

  • PreethipreethuPreethipreethu Posts: 4Questions: 1Answers: 0

    sorry, i dont have link available right now, but i can send you the js file, please go through that code snippet for keyup and down navigation for datatable row selection, that code working fine to select the data table row, but its not scrolling with keydown or up function.

    //code snipped for keydown and up navigation for datatable.

    $('#partyListTableID tbody').on( 'mouseover', 'tr', function (e) {
    var tr = $(this);

            if ( $(this).hasClass('selected') ) {
    
               $(this).removeClass('selected');
    
            }
    
            else {
    
                partyTableOTable.$('tr.selected').removeClass('selected');
    
                $(this).addClass('selected');
    
            }        
    
          //on keypress within tr
    
            $(document).keydown(function(e) {
    
    
            //var tabla = document.getElementById("partyListTableID");
    
            //var fila = tabla.getElementsByClassName('odd selected');
    
            //var fila2 = tabla.getElementsByClassName('even selected');
    
            if (e.keyCode == 40){ //arrow down
    
                partyTableOTable.$('tr.selected').removeClass('selected');
    
                tr.next().addClass('selected');
    
                tr = partyTableOTable.$('tr.selected');
            }
    
            if (e.keyCode == 38){ //arrow up
                 partyTableOTable.$('tr.selected').removeClass('selected');
                tr.prev().addClass('selected');
                tr = partyTableOTable.$('tr.selected');
    
                }
    
            })
    
      } ); 
    

    here, when i mouseover on the datatable, arrow keyup and down working but not scrolling.

  • PreethipreethuPreethipreethu Posts: 4Questions: 1Answers: 0

    here, i sent working page image, when i reach last row on the table, arrow keys not scrolling to view next row on the datatable

  • allanallan Posts: 64,756Questions: 1Answers: 10,716 Site admin

    I don't see anything in your code that will handle the scrolling for the table.

    If you want to implement this yourself, you could have a look at the KeyTable implementation of that action and see how it handles it, then base your code on that.

    Allan

  • PreethipreethuPreethipreethu Posts: 4Questions: 1Answers: 0

    thank you @ allan for spent your precious time to hv look at code.

This discussion has been closed.