Search code examples
jqgridjscrollpanejquery-jscrollpane

How to use jScrollPane with jqgrid?


How to use JScrollPane with jqgrid? I tried to use it but the headers are not moving. Here is my code.

       gridComplete:function(){
$('#gview_mygrid >div.ui-jqgrid-bdiv').jScrollPane({ showArrows: true, scrollbarWidth: 17, arrowSize: 17, scrollbarMargin: 0 });}

Solution

  • Finally I figured it out.. Here is the working code. In the markup

     <div id="container" >  
            <table id="list"><tr><td/></tr></table>
            <div id="pager"></div>
      </div>
    

    IN Java script, We have to bind the header (class .ui-jqgrid-hbox) also to scroll

    gridComplete:function(){
                 var table_header = $('#container').find('.ui-jqgrid-hbox').css("position","relative");
                 $('#container').find('.ui-jqgrid-bdiv').bind('jsp-scroll-x', function(event, scrollPositionX, isAtLeft, isAtRight) {
                                table_header.css('right', scrollPositionX);
                               }).jScrollPane({
                                 showArrows: true, 
                                autoReinitialise: true,
                                horizontalDragMaxWidth: 30,
                                verticalDragMaxHeight: 30           
                            });
                         }