mar10 / fancytree

JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading
http://wwwendt.de/tech/fancytree/demo
Other
2.84k stars 604 forks source link

Sticky headers and/or columns #184

Closed patrickmallahan closed 10 years ago

patrickmallahan commented 10 years ago

I'd like to submit a feature request to allow the column headers and/or a defined column to be sticky to the top or left whether or not it is inside a scrollable div. Here's an example on how to apply it to a vanilla table, however, when trying to apply this to a fancytree table, it doesn't work:

http://tympanus.net/codrops/2014/01/09/sticky-table-headers-columns/

If you need any help with bugs or feature requests, let me know.

mar10 commented 10 years ago

Hi,

I tried it and adding this seemed to work:

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-throttle-debounce/1.1/jquery.ba-throttle-debounce.min.js"></script>
<script src="js/jquery.stickyheader.js"></script>

...

<style type="text/css">
.sticky-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    margin: 3em 0;
    width: 100%;
}
.sticky-wrap .sticky-thead,
.sticky-wrap .sticky-col,
.sticky-wrap .sticky-intersect {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    transition: all .125s ease-in-out;
    z-index: 50;
    width: auto; /* Prevent table from stretching to full size */
}
.sticky-wrap .sticky-thead {
    box-shadow: 0 0.25em 0.1em -0.1em rgba(0,0,0,.125);
    z-index: 100;
    width: 100%; /* Force stretch */
    background-color: seashell;
}
.sticky-wrap .sticky-intersect {
    opacity: 1;
    z-index: 150;

}
.sticky-wrap .sticky-intersect th {
    background-color: #666;
    color: #eee;
}
.sticky-wrap td,
.sticky-wrap th {
    box-sizing: border-box;
}
</style>