最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I insert a scrollbar in jquery jtable? - Stack Overflow

programmeradmin1浏览0评论

I am using the great jquery plugin jtable. But I can't find any examples showing a vertical scrollbar.

I tried setting a height and overflow.auto on the div that contains it - the scrollbar then scrolls the whole table including header - I only want to scroll the rows not the header and not the footer.

Has anyone found a way to do this?

A solution that works some way is inserting:

$('.jtable').wrap('<div class="jtable-main-container scroll-content" />');    

and

.scroll-content {
     overflow-y: auto;
    width:100%;
 }
div.jtable-main-container {
  height:100%;
}

And setting height on the div. However it also scrolls the table header - but it is better than scrolling the whole jtable - I tried to make a solution where jtable generates 2 tables - one with header and one with body but the header gets out of sync.

see it here: /

I am using the great jquery plugin jtable. But I can't find any examples showing a vertical scrollbar.

I tried setting a height and overflow.auto on the div that contains it - the scrollbar then scrolls the whole table including header - I only want to scroll the rows not the header and not the footer.

Has anyone found a way to do this?

A solution that works some way is inserting:

$('.jtable').wrap('<div class="jtable-main-container scroll-content" />');    

and

.scroll-content {
     overflow-y: auto;
    width:100%;
 }
div.jtable-main-container {
  height:100%;
}

And setting height on the div. However it also scrolls the table header - but it is better than scrolling the whole jtable - I tried to make a solution where jtable generates 2 tables - one with header and one with body but the header gets out of sync.

see it here: http://jsfiddle/j5Q4L/3/

Share Improve this question edited Aug 25, 2013 at 20:21 Rune Andersen asked Apr 19, 2013 at 22:01 Rune AndersenRune Andersen 1,70512 silver badges16 bronze badges 1
  • 2 Have you got an answer to this question?Then plz do share...because iam also facing the same issue... :( – Mothy Commented Jan 23, 2014 at 6:35
Add a ment  | 

3 Answers 3

Reset to default 3
$('.jtable').wrap('<div class="jtable-main-container scroll-content" />');    
and

.scroll-content {
     overflow-y: auto;
    width:100%;
 }
div.jtable-main-container {
  height:100%;
}

Thank you!

  <style type="text/css">
        #StudentTableContainer {
            width: 100%;
            display: block;
        }

            #StudentTableContainer tbody, .jtable tbody {
                height: 100px;
                overflow-y: auto;
                display: block;
            }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#StudentTableContainer').jtable({
                //...
            });
        });
    </script>
    <div id="StudentTableContainer" class="jtable"></div>

Add this to css

table.jtable{
overflow-y: scroll;
display:block;
overflow-x: hidden;
}
发布评论

评论列表(0)

  1. 暂无评论