1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
| <head id="Head1" runat="server">
<title></title>
<script src="/script/jquery-1.9.0.js" type="text/javascript"></script>
<style type="text/css">
table
{
border-collapse: collapse;
}
td
{
border: 1px solid;
}
.general
{
position: absolute;
overflow: hidden;
border: 1px solid;
}
.entete
{
position: absolute;
left: 0px;
top: 0px;
position: absolute;
background-color: #99CCCC;
}
.Cellule
{
width: 100px;
}
.pied
{
position: absolute;
left: 0px;
bottom: 0px;
background-color: #99CCCC;
}
.donnees
{
position: absolute;
overflow: hidden;
left: 0px;
background-color: #9999CC;
}
</style>
<script type="text/javascript">
$(function () {
var hsb = getScrollBarWidth();
var HautTot = 250;
$("#datas").css("max-height", HautTot - parseInt($("#tete").css('height')) - parseInt($("#Foot").css('height')) + "px");
/*Largeur totale du tableau*/
var LargTot = 400;
$("#gene").css("width", LargTot + "px");
$("#tete").css("width", LargTot + "px");
$("#datas").css("width", LargTot + "px");
$("#Foot").css("width", LargTot + "px");
/*Hauteur globale de départ*/
$("#gene").css("height", parseInt($("#tete").css('height')) + parseInt($("#Foot").css('height')) + "px");
/*Positionner les datas*/
$("#datas").css("top", parseInt($("#tete").css('height')) + "px");
$("#tbdatas").css("width", LargTot + "px");
$("#btnAdd").click(function () {
var HL = 50;
var row = '<tr height=' + HL + '><td class="Cellule">1</td><td class="Cellule">2</td><td class="Cellule">3</td><td class="Cellule">4</td></tr>';
$('#tbdatas').append(row);
var Siz = parseInt($("#gene").css('height'));
if (Siz + HL < HautTot) {
$("#gene").css("height", Siz + HL + "px");
}
else {
/*Elargir pour mettre scroll vertical en dehors du tableau*/
if (parseInt($("#gene").css('padding-right'))!=hsb) {
$("#gene").css("padding-right", hsb + "px");
$("#datas").css("padding-right", hsb + "px");
$("#datas").css("overflow", "scroll");
$("#datas").css("overflow-x", "hidden");
}
}
});
});
function getScrollBarWidth() {
var width = 100, $outer = $('<div>').css({ visibility: 'hidden', width: width, overflow: 'scroll' }).appendTo('body'), widthWithScroll = $('<div>').css({ width: '100%' }).appendTo($outer).outerWidth();
$outer.remove();
return width - widthWithScroll;
};
</script>
</head>
<body>
<button id="btnAdd">
Ajouter 1 ligne</button>
<div class="general" id="gene">
<div class="entete" id="tete">
<table>
<tr>
<td class="Cellule">
Alpha
</td>
<td class="Cellule">
Beta
</td>
<td class="Cellule">
Gamma
</td>
<td class="Cellule">
Omega
</td>
</tr>
</table>
</div>
<div class="donnees" id="datas">
<table id="tbdatas">
</table>
</div>
<div class="pied" id="Foot">
<table>
<tr>
<td class="Cellule">
a
</td>
<td class="Cellule">
b
</td>
<td class="Cellule">
g
</td>
<td class="Cellule">
o
</td>
</tr>
</table>
</div>
</div>
</body> |
Partager