//////////Use Jquery Plugin
////////////////////// html
//////////////////////// JS
/////////////// Result
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
//////////// css
<style type="text/css">
.scrollTblGrid table
{
border-collapse: collapse;
width: 300px;
overflow-x: scroll;
display: block;
}
.scrollTblGrid thead
{
background-color: #EFEFEF;
}
.scrollTblGrid thead,
.scrollTblGrid tbody
{
display: block;
}
.scrollTblGrid tbody
{
overflow-y: scroll;
overflow-x: hidden;
height: 140px;
}
.scrollTblGrid td,
.scrollTblGrid th
{
min-width: 100px;
height: 25px;
border: dashed 1px lightblue;
overflow:hidden;
text-overflow: ellipsis;
max-width: 100px;
}
</style>
////////////////////// html
<div class="scrollTblGrid">
<table id="tbljaiho">
<thead>
<tr><th>Column 1</th><th>Column 2</th><th>Column 3</th><th>Column 4</th><th>Column 5</th></tr>
</thead>
<tbody>
<tr><td>AAAAAAAAAAAAAAAAAAAAAAAAAA</td><td>Row 1</td><td>Row 1</td><td>Row 1</td><td>Row 1</td></tr>
<tr><td>Row 2</td><td>Row 2</td><td>Row 2</td><td>Row 2</td><td>Row 2</td></tr>
<tr><td>Row 3</td><td>Row 3</td><td>Row 3</td><td>Row 3</td><td>Row 3</td></tr>
<tr><td>Row 4</td><td>Row 4</td><td>Row 4</td><td>Row 4</td><td>Row 4</td></tr>
<tr><td>Row 5</td><td>Row 5</td><td>Row 5</td><td>Row 5</td><td>Row 5</td></tr>
<tr><td>Row 6</td><td>Row 6</td><td>Row 6</td><td>Row 6</td><td>Row 6</td></tr>
<tr><td>Row 7</td><td>Row 7</td><td>Row 7</td><td>Row 7</td><td>Row 7</td></tr>
<tr><td>Row 8</td><td>Row 8</td><td>Row 8</td><td>Row 8</td><td>Row 8</td></tr>
<tr><td>Row 9</td><td>Row 9</td><td>Row 9</td><td>Row 9</td><td>Row 9</td></tr>
<tr><td>Row 10</td><td>Row 10</td><td>Row 10</td><td>Row 10</td><td>Row 10</td></tr>
</tbody>
</table>
</div>
//////////////////////// JS
<script type="text/javascript">
//$(window).load(function(){
//$('table').on('scroll', function
() {
// $("table >
*").width($("table").width() +
$("table").scrollLeft());
//});
//});
$(window).load(function () {
$('#tbljaiho').on('scroll',
function () {
$("#tbljaiho >
*").width($("#tbljaiho").width()
+ $("#tbljaiho").scrollLeft());
});
});
</script>
No comments:
Post a Comment