IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Dimensionner largeur de colonne


Sujet :

jQuery

  1. #1
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut Dimensionner largeur de colonne
    Bonjour,

    voici mon code html :
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <div class="fix_table">
    	<div class="fix_table_header">
    		<table>
    			<thead>
    				<tr>
    					<th>mon header 1</th>
    					<th>mon header 2</th>
    					<th>mon header 3</th>
    					<th>mon header 4</th>
    				</tr>
    			</thead>
    			<tbody style="display:none"><tr><td></td></tr></tbody> <!-- pour etre valide W3C -->
    		</table>
    	</div>
     
    	<div class="fix_table_body" style="height:10em;overflow-Y:auto;">
    		<table>				
    			<tbody>
    				<tr>
    					<td>col 1</td>
    					<td>col 2</td>
    					<td>col 3</td>
    					<td>col 4</td>
    				</tr>
    			</tbody>
    		</table>
    	</div>
    </div>

    Je cherche à faire un tableau avec une entete fixe et le corps scrollable verticalement : c'est pourquoi, on peut voir que mon tableau est divisé en deux tableaux.

    Ce que je voudrais c'est dimensionner la largeur des colonnes du second tableau en fonctions de la largeur des colonnes du premier tableau.

    Comment feriez-vous ?

    Aussi, comment faites-vous pour récupérer le nombre de colonnes et de lignes d'un tableau ?

    Merci d'avance,

  2. #2
    Inactif  

    Homme Profil pro
    développeur Vala
    Inscrit en
    Février 2011
    Messages
    478
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Cher (Centre)

    Informations professionnelles :
    Activité : développeur Vala
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2011
    Messages : 478
    Par défaut
    si ton nombre de colonnes est limité, je te conseille d'attribuer la même classe à chaque colonne.

  3. #3
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    Citation Envoyé par rotrevrep Voir le message
    si ton nombre de colonnes est limité, je te conseille d'attribuer la même classe à chaque colonne.
    Je ne connais pas à l'avance le nombre de colonne donc ça ne sera pas possible (à moins que tu connaisses une méthode pour créer des class à la volée).

    Actuellement je fais ça pour configurer mon tableau mais ça ne fonctionne correctement uniquement sous firefox :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    // ******************************************************
    // creation des tableaux avec scrollbar verticale
    function initFixedTable(){
     
    	var divDivTabList = $("div.fix_table");
     
    	for (var i=0; i<divDivTabList.length; i++){ // parcours de tous les "div.fix_table"
     
    		var divTabList = $(divDivTabList[i]).children("div"); // récupération de de tous les "div.fix_table > div"
    		var tabHeader = $(divTabList[0]).children("table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_header > table"
    		var tabBody = $(divTabList[1]).children("table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_body > table"
     
    		var tabHeaderLines = $(tabHeader).find("tr");
    		var tabBodyLines = $(tabBody).find("tr");
     
    		//alert(tabHeaderLines.length); // nombre de ligne		
    		//alert($(tabHeaderLines[0]).children().length); // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
     
     
    		//*
    		var scrollBarWidth = getScrollerWidth();
     
    		var widthLine = $(tabHeaderLines[0]).width();
    		var widthDiv = $(divTabList[0]).width();
    		$(divTabList[1]).width(widthDiv + scrollBarWidth);
     
    		//$(divTabList[0]).width(widthDiv);
     
    		$(tabBodyLines[0]).width(widthLine);
     
    		var headColumnCount = $(tabHeaderLines[0]).children().length; // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
    		for(j=0; j<headColumnCount; j++){
    			var columnTmp = $(tabHeaderLines[0]).children()[j];
    			var widthColumn = $(columnTmp).width(); //alert(widthColumn);
    			$($(tabBodyLines[0]).children()[j]).width(widthColumn);
    		}
    		// => TODO : on fait quoi si le tableau est vide ?
    		// */
    	}
    }
     
    function getScrollerWidth() {
        var scr = null;
        var inn = null;
        var wNoScroll = 0;
        var wScroll = 0;
     
        // Outer scrolling div
        scr = document.createElement('div');
        scr.style.position = 'absolute';
        scr.style.top = '-1000px';
        scr.style.left = '-1000px';
        scr.style.width = '100px';
        scr.style.height = '50px';
        // Start with no scrollbar
        scr.style.overflow = 'hidden';
     
        // Inner content div
        inn = document.createElement('div');
        inn.style.width = '100%';
        inn.style.height = '200px';
     
        // Put the inner div in the scrolling div
        scr.appendChild(inn);
        // Append the scrolling div to the doc
        document.body.appendChild(scr);
     
        // Width of the inner div sans scrollbar
        wNoScroll = inn.offsetWidth;
        // Add the scrollbar
        scr.style.overflow = 'auto';
        // Width of the inner div width scrollbar
        wScroll = inn.offsetWidth;
     
        // Remove the scrolling div from the doc
        document.body.removeChild(
            document.body.lastChild);
     
        // Pixel width of the scroller
        return (wNoScroll - wScroll);
    }

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    code complet pour debuger :
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
    <head>
    	<title>test</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     
    	<style type='text/css'>
    body{
    min-width: 650px;
    margin:0;
    padding:0;
    border:none;
    font-family: Verdana, Arial, sans-serif;
    color:black;
    font-size:0.8em;
    background-color:#ebecf6;
    height:100%; /* pour layout ie6 */
    }
     
    div {
    font-size:1em;
    display:block;
    margin:0;
    padding:0;
    }
     
    a, h1, h2, h3, h4, h5, p{
    font-size:1em;
    margin:0.3em 0;
    padding:0;
    border:none
    }
     
    .spacer { 
    clear: both; 
    } 
     
    .spacer hr{     
      display: none; 
    }
     
     
    div.blocTab{
    clear: both;
    float:left;
    margin: 5px 0px 10px 5px ;
    background-color:red;
    color:white;
    font-size:1em;
    }
     
    div.blocTab h3{
    font-weight:bold;
    font-size:1em;
    margin:0 4em 0 0;
    padding:3px 5px 3px 20px;
    background-position : -171px -65px;
    }
     
    div.blocTab table{
    padding:0;
    margin:2px;
    font-size:0.9em;
    border-collapse:collapse;
    border:none;
    background-color:red;
    color:#00039e}
     
    div.blocTab th{
    font-weight:bold;
    background-color:blue;
    color:white;
    font-weight:bold;
    }
     
    div.blocTab th a{
    display:block;
    float:right;
     
    height:10px;
    width:10px;
    padding:0;
    margin:2px 0 0 2px;
     
    background-position : -86px -65px;
    }
     
    div.blocTab th, td{
    border:2px solid white;
    text-align:center;
    padding:2px 10px;
    margin:0}
     
     
    div.blocTab tr{
    background-color:green;
    margin:0;
    padding:0;
    }
    div.blocTab tr.tr_imp{background-color:#dbe5f6;}
    div.blocTab select{
    margin:0;
    padding:0;
    font-size:1.1em;
    }
    div.blocTab input{
    margin:0 0.5em;
    padding:0.1em 0.2em;
    font-size:1.1em;
    }
     
     
    div.blocTab div.tabPageSelect{
    padding:2px;
    font-weight:bold;
    text-align:center;
    /*border-bottom: 2px solid white;*/
    /*margin-bottom: 4px;*/
    }
     
     
    	</style>
     
    	<script type="text/javascript" src="jquery-1.4.2.js"></script>
     
    	<script type="text/javascript"> 
    //<![CDATA[ 
     
     
    // code executé au demarrage
    $(document).ready(function(){   // Traitement à effectuer lorsque le DOM est prêt
    //$(window).load(function(){            // Traitement à effectuer lorsque tous les elements de la page sont chargés
     
            initFixedTable();
     
    });   
     
     
    // ******************************************************
    // creation des tableaux avec scrollbar verticale
    function initFixedTable(){
     
            var divDivTabList = $("div.fix_table");
            
            for (var i=0; i<divDivTabList.length; i++){ // parcours de tous les "div.fix_table"
            
                    var divTabList = $(divDivTabList[i]).children("div"); // récupération de de tous les "div.fix_table > div"
                    var tabHeader = $(divTabList[0]).children("table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_header > table"
                    var tabBody = $(divTabList[1]).children("table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_body > table"
     
                    var tabHeaderLines = $(tabHeader).find("tr");
                    var tabBodyLines = $(tabBody).find("tr");
     
                    //alert(tabHeaderLines.length); // nombre de ligne              
                    //alert($(tabHeaderLines[0]).children().length); // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
     
                                    
                    //*
                    var scrollBarWidth = getScrollerWidth();
                    
                    var widthLine = $(tabHeaderLines[0]).width();
                    var widthDiv = $(divTabList[0]).width();
                    $(divTabList[1]).width(widthDiv + scrollBarWidth);
                    
                    //$(divTabList[0]).width(widthDiv);
                    
                    $(tabBodyLines[0]).width(widthLine);
                                    
                    var headColumnCount = $(tabHeaderLines[0]).children().length; // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
                    for(j=0; j<headColumnCount; j++){
                            var columnTmp = $(tabHeaderLines[0]).children()[j];
                            var widthColumn = $(columnTmp).width(); //alert(widthColumn);
                            $($(tabBodyLines[0]).children()[j]).width(widthColumn);
                    }
                    // => TODO : on fait quoi si le tableau est vide ?
                    // */
            }
    }
     
    function getScrollerWidth() {
        var scr = null;
        var inn = null;
        var wNoScroll = 0;
        var wScroll = 0;
     
        // Outer scrolling div
        scr = document.createElement('div');
        scr.style.position = 'absolute';
        scr.style.top = '-1000px';
        scr.style.left = '-1000px';
        scr.style.width = '100px';
        scr.style.height = '50px';
        // Start with no scrollbar
        scr.style.overflow = 'hidden';
     
        // Inner content div
        inn = document.createElement('div');
        inn.style.width = '100%';
        inn.style.height = '200px';
     
        // Put the inner div in the scrolling div
        scr.appendChild(inn);
        // Append the scrolling div to the doc
        document.body.appendChild(scr);
     
        // Width of the inner div sans scrollbar
        wNoScroll = inn.offsetWidth;
        // Add the scrollbar
        scr.style.overflow = 'auto';
        // Width of the inner div width scrollbar
        wScroll = inn.offsetWidth;
     
        // Remove the scrolling div from the doc
        document.body.removeChild(
            document.body.lastChild);
     
        // Pixel width of the scroller
        return (wNoScroll - wScroll);
    }
     
     
    //]]>
            </script>
     
    </head>
     
    <body style="min-width: 800px;">
     
    	<div id="corps">
    		<noscript><h1>Erreur : Javascript est désactivé</h1></noscript>
     
    			<div class="blocTab fix_table">
    				<h3>Mon Titre</h3>
    				<div class="fix_table_header">
    					<table>
    						<thead>
    							<tr>
    								<th>ma colonne 1</th>
    								<th>ma colonne 2</th>
    								<th>ma colonne 3</th>
    								<th>ma colonne 4</th>
    							</tr>
    						</thead>
    						<tbody style="display:none"><tr><td></td></tr></tbody> <!-- pour etre valide W3C -->
    					</table>
    				</div>
     
    				<div class="fix_table_body" style="height:10em;overflow-Y:auto;">
    					<table>				
    						<tbody>
    							<tr>
    								<td>1</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>2</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>3</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>4</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
     
    							<tr>
    								<td>5</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>1</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>2</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>3</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>4</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
     
    							<tr>
    								<td>5</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    						</tbody>
    					</table>
    				</div>
    			</div>
    			<div class="spacer"></div>
     
    		</div>
     
    		<div class="spacer"><hr/></div>
    	</div>
     
    </body>
    </html>

    => penser à mettre le bon chemin pour la lib Jquery

  5. #5
    Rédacteur
    Avatar de Macmillenium
    Homme Profil pro
    Développeur front-end
    Inscrit en
    Mars 2008
    Messages
    2 333
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur front-end
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2008
    Messages : 2 333
    Par défaut
    J'ai pas le courage de lire ton code...
    Essaye ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    var cells1 = $('.fix_table_header').find('td, th'),
        cells2 = $('.fix_table_body').find('td, th'),
        cellsWidthArray = [];
     
    cells1.each(function(i) {
      cellsWidthArray[i] = $(this).width();
    });
     
    cells2.each(function(i) {
      $(this).width(cellsWidthArray[i])
    });

  6. #6
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    Non, ça ne fonctionne pas : Lorsque la scrollbar s'active, les largeurs des cellules du tableau contenant les données est automatiquement redimensionné

  7. #7
    Membre expérimenté
    Inscrit en
    Décembre 2009
    Messages
    282
    Détails du profil
    Informations forums :
    Inscription : Décembre 2009
    Messages : 282
    Par défaut
    j'avais fait une petite fonction pour ca, tu passais la table en argument et elle te fixait les headers (en créant un div avec les headers et un div avec le contenu). Après y'avait pas mal de truc a faire attention :
    - les colspans faisait souvent des décalages de pixels
    - les cellpadding, cellspacing et border
    - le overflow, la barre à droite est contenu dans l'attribut "width" sur firefox et pas sur IE (ou le contraire ^^)
    - modification de la taille de la page, ca entraine souvent une modification de la taille de la table
    - et y'avait encore d'autre truc ....

    C'est pas si simple que ca a faire..je vais essayer de la refaire aujourd'hui je me fais chi.. au boulot, je te filerais le code quand je réussis si tu veux

  8. #8
    Invité
    Invité(e)

  9. #9
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    Citation Envoyé par jreaux62 Voir le message
    Bonjour,
    j'ai vu ça en passant : Pure CSS Scrollable Table with Fixed Header
    (non testé)
    Ne fonctionne pas sur IE7 et 8 (9 pas testé)

  10. #10
    Invité
    Invité(e)
    Par défaut
    Exact.
    Il faut peut-être envisager une version alternative pour I.E.

    Ou boycotter I.E., qui est le seul à nous faire autant ch.. en nous obligeant à coder 3 fois plus, rien que pour ses versions pourries...

  11. #11
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    J'ai trouvé une solution qui marche (sauf sur IE7 => mais l'affichage n'est pas trop degueu) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
    <head>
    	<title>test</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     
    	<style type='text/css'>
    body{
    min-width: 650px;
    margin:0;
    padding:0;
    border:none;
    font-family: Verdana, Arial, sans-serif;
    color:black;
    background-color:#ebecf6;
    height:100%; /* pour layout ie6 */
    }
     
    display:block;
    margin:0;
    padding:0;
    }
     
    a, h1, h2, h3, h4, h5, p{
    margin:0.3em 0;
    padding:0;
    border:none
    }
     
    .spacer { 
    clear: both; 
    } 
     
    .spacer hr{     
      display: none; 
    }
     
     
    div.blocTab{
    clear: both;
    float:left;
     
    margin: 5px 0px 10px 5px ;
    background-color:red;
    color:white;
    }
     
    div.blocTab h3{
    font-weight:bold;
    margin:0 4em 0 0;
    padding:3px 5px 3px 20px;
    background-position : -171px -65px;
    }
     
    div.blocTab table{
    padding:0;
    margin:0;
     
    border-collapse:collapse;
    border:none;
    background-color:red;
    color:#00039e}
     
    div.blocTab th{
    font-weight:bold;
    background-color:blue;
    color:white;
    font-weight:bold;
    }
     
    div.blocTab th a{
    display:block;
    float:right;
     
    height:10px;
    width:10px;
    padding:0;
    margin:2px 0 0 2px;
     
    background-position : -86px -65px;
    }
     
    div.blocTab th, td{
    border:2px solid white;
    text-align:center;
    padding:2px 10px;
    margin:0}
     
     
    div.blocTab tr{
    background-color:green;
    margin:0;
    padding:0;
    }
    div.blocTab tr.tr_imp{background-color:#dbe5f6;}
    div.blocTab select{
    margin:0;
    padding: 0 2px 2px 2px;
    }
     
     
    div.blocTab div.fix_table_body{
    height:10em;
    overflow-y:scroll;
    /*overflow-y:auto;*/
    overflow-x:visible;
    }
     
    div.blocTab div.fix_table_body  table{
    /*width:100%;*/
    }
     
    	</style>
     
    	<script type="text/javascript" src="jquery-1.4.2.js"></script>
     
    	<script type="text/javascript"> 
    //<![CDATA[ 
     
     
    // code executé au demarrage
    $(document).ready(function(){	// Traitement à effectuer lorsque le DOM est prêt
    //$(window).load(function(){		// Traitement à effectuer lorsque tous les elements de la page sont chargés
     
    	//initFixedTable();
     
    });   
     
    // ******************************************************
    // creation des tableaux avec scrollbar verticale
    var widthColumn = []; // sert a redefinir la largeur des cases du tableau quand on le met a jour
    function initFixedTable(){
     
    	var divDivTabList = $("div.fix_table");
     
    	for (var i=0; i<divDivTabList.length; i++){ // parcours de tous les "div.fix_table"
     
    		var divTabList = $(divDivTabList[i]).children("div"); // récupération de de tous les "div.fix_table > div"
    		var tabHeader = $(divTabList[0]).children("table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_header > table"
    		var tabBody = $(divTabList[1]).children("table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_body > table"
     
    		var tabHeaderLines = $(tabHeader).find("tr");
    		var tabBodyLines = $(tabBody).find("tr");
     
    		//alert(tabHeaderLines.length); // nombre de ligne		
    		//alert($(tabHeaderLines[0]).children().length); // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
     
     
    		//var scrollBarWidth = getScrollerWidth();
     
    		//var widthLine = $(tabHeaderLines[0]).width();
    		//var widthDiv = $(divTabList[0]).width();
    		//$(divTabList[1]).width(widthDiv + scrollBarWidth);
     
    		//$(divTabList[0]).width(widthDiv);
     
    		//$(tabBodyLines[0]).width(widthLine);
     
    		//*
     
    		//*
    		var widthTabBody = $(tabBody).width();
    		//alert("get TabBody: " + widthTabBody);
    		$(tabHeader).width(widthTabBody); // +2 sur firefox
    		var widthTabHead = $(tabHeader).width();
    		//alert("get TabHead: " + widthTabHead);
     
    		// le get width et le set width ne renvoit pas la meme chose
    		// => on corrige l'erreur
    		var diffWidth = widthTabBody - widthTabHead;
    		widthTabHead = widthTabBody + diffWidth;
     
    		$(tabHeader).width(widthTabHead);
     
    		//if($(tabHeader).width() != $(tabBody).width()){
    		//	alert("get TabHead: " + $(tabHeader).width());
    		//	alert("get tabBody: " + $(tabBody).width());		
    		//} else {
    		//	alert("TabHead/tabBody width: OK");
    		//}
     
    		$(tabBody).width(widthTabHead); // on fige aussi le body pour éviter tout problème si l'unité n'est pas de type absolue (ex : em)
     
     
    		//*		
    		// ************************************************
    		var headColumnCount = $(tabHeaderLines[0]).children().length; // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
    		var diffWidthColumn = [];
     
    		for(j=0; j<headColumnCount; j++){
    			var columnTmp = $(tabHeaderLines[0]).children()[j];
    			widthColumn[j] = $(columnTmp).width(); //alert(widthColumn);
    		}
     
     
    		//alert("set colonne width: " + widthColumn[0]);
    		$($(tabBodyLines[0]).children()[0]).width(widthColumn[0]);
    		//alert("get colonne width: " + $($(tabBodyLines[0]).children()[0]).width());
     
    		diffWidthColumn = widthColumn[0] - $($(tabBodyLines[0]).children()[0]).width(); // calcul de la correction d'erreur
    		//alert(diffWidthColumn);
     
    		for(j=0; j<headColumnCount; j++){
    		//for(j=0; j<1; j++){
    			widthColumn[j] += diffWidthColumn;
    			$($(tabBodyLines[0]).children()[j]).width(widthColumn[j]);
     
    			// control d'erreur
    			//if ($($(tabHeaderLines[0]).children()[j]).width() != $($(tabBodyLines[0]).children()[j]).width()){
    			//	alert("Erreur0 largeur colonne: " + j);
    			//} else {
    			//	alert("largeur colonne OK: " + j);
    			//}
    		}
     
     
    		// on fige aussi le head pour éviter tout problème si l'unité n'est pas de type absolue (ex : em)
    		for(j=0; j<headColumnCount; j++){
    			$($(tabHeaderLines[0]).children()[j]).width(widthColumn[j]);
    		}
     
     
    		// control d'erreur
    		//for(j=0; j<headColumnCount; j++){
    		//	if ($($(tabHeaderLines[0]).children()[j]).width() != $($(tabBodyLines[0]).children()[j]).width()){
    		//		alert("Erreur largeur colonne: " + j);
    		//	}
    		//}
    		// => TODO : on fait quoi si le tableau est vide ?
    		// */
     
     
     
    	}
    }
     
     
     
    //]]>
    	</script>
     
    </head>
     
    <body style="min-width: 800px;">
     
    	<div id="corps">
    		<noscript><h1>Erreur : Javascript est désactivé</h1></noscript>
     
    			<div class="blocTab fix_table" id="tableLogBloc" style="float:clear;width:600px;">
    				<h3>Mon Titre</h3>
    				<div class="fix_table_header">
    					<table>
    						<thead>
    							<tr>
    								<th>ma colonne 1</th>
    								<th>ma colonne 2</th>
    								<th>ma colonne 3</th>
    								<th>ma colonne 4</th>
    							</tr>
    						</thead>
    						<tbody style="display:none"><tr><td></td></tr></tbody> <!-- pour etre valide W3C -->
    					</table>
    				</div>
     
    				<div class="fix_table_body" style="height:10em;">
    					<table>
    						<tbody>
    							<tr>
    								<td>1</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>2</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>3</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>4</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
     
    							<tr>
    								<td>5</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>1</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>2</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>3</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    							<tr>
    								<td>4</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
     
    							<tr>
    								<td>5</td>
    								<td></td>
    								<td></td>
    								<td></td>
    							</tr>
     
    						</tbody>
    					</table>
    				</div>
    			</div>
    			<div class="spacer"></div>
     
    		</div>
     
    		<div class="spacer"><hr/></div>
    	</div>
     
    </body>
    </html>
    Testé sous : Opera 10.52, Safari 3.2.2, Chrome 7.0.517.41, IE8, IE9
    Testé aussi (avec IETester) sur : IE6, IE7(affichage incorrecte)


    Le principe de fonctionnement est simple : je récupère la largeur du tableau qui est scrollable (ce tableau a un width: 100% => donc il prend toute la zone et la barre de scroll est affichée) puis je l'applique au tableau de l’entête. Ensuite je recupère la taille des colonnes de l’entête et je les applique au colonnes du tableau scrollable.

    => le problème avec IE7 c'est si width de la table scrollable = 100%, la table dépasse la zone en largeur (désactiver le js pour voir le problème) : vous avez compris le problème ?

    Une solution pour résoudre le problème ?


    -------------------------
    aussi, il y a ce plug-in qui le gère : http://datatables.net/
    => mais je n'ai pas bien compris comment il fait...
    => je ne l'utilise pas car je suis limité en taille de fichier (système embarqué) : le plug-in est assez gros mais la partie de la gestion du scrollback à l'air assez petite

  12. #12
    Rédacteur
    Avatar de Macmillenium
    Homme Profil pro
    Développeur front-end
    Inscrit en
    Mars 2008
    Messages
    2 333
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur front-end
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2008
    Messages : 2 333
    Par défaut
    Tu te compliques trop la vie.

    Citation Envoyé par boboss123 Voir le message
    Non, ça ne fonctionne pas : Lorsque la scrollbar s'active, les largeurs des cellules du tableau contenant les données est automatiquement redimensionné
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $('.fix_table_header').find('table').width($('.fix_table_body').find('table').outerWidth())
    outerWidth() tient compte du box model et inclut donc les border et padding.

    Pour IE7 il affiche la scrollbar à l'intérieur du bloc, c'est un bug connu et documenté.

  13. #13
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    merci pour l'information, c'est toujours bon à savoir même si ça ne résoud pas vraiment mon problème.

    Ma solution actuelle me semble pas mal : vous en pensez quoi ?
    => Pour avoir un affichage parfait, reste juste à avoir le bon code CSS pour que la définition de la largeur de "div.blocTab div.fix_table_body table" rentre dans "div.blocTab div.fix_table_body" sans déclancher d'overflow sous IE7 (désactiver le js de mon code de test pour voir le problème de css)

    vous savez pourquoi, j'ai ça sur certains navigateurs ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    $(elmt).width(setVal);
    getVal = $(elmt).width();
    // Sur certain navigateurs, getVal  != setVal (de quelques pixels)
    // => C'est pourquoi j'ai inclus un correctif d'erreur

  14. #14
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    J'ai trouvé une solution pour que ça fonctionne aussi sous IE7 : il faut que je mette le tableau dans un div (ça commence à faire pas mal de div XD ) :

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
    <head>
    	<title>test</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     
    	<style type='text/css'>
    body{
    min-width: 650px;
    margin:0;
    padding:0;
    border:none;
    font-family: Verdana, Arial, sans-serif;
    color:black;
    background-color:#ebecf6;
    height:100%; /* pour layout ie6 */
    }
     
    display:block;
    margin:0;
    padding:0;
    }
     
    a, h1, h2, h3, h4, h5, p{
    margin:0.3em 0;
    padding:0;
    border:none
    }
     
    .spacer { 
    clear: both; 
    } 
     
    .spacer hr{     
      display: none; 
    }
     
     
    div.blocTab{
    clear: both;
    float:left;
     
    margin: 5px 0px 10px 5px ;
    background-color:red;
    color:white;
    }
     
    div.blocTab h3{
    font-weight:bold;
    margin:0 4em 0 0;
    padding:3px 5px 3px 20px;
    background-position : -171px -65px;
    }
     
    div.blocTab table{
    padding:0;
    margin:0;
     
    border-collapse:collapse;
    border:none;
    background-color:red;
    color:#00039e}
     
    div.blocTab th{
    font-weight:bold;
    background-color:blue;
    color:white;
    font-weight:bold;
    }
     
    div.blocTab th a{
    display:block;
    float:right;
     
    height:10px;
    width:10px;
    padding:0;
    margin:2px 0 0 2px;
     
    background-position : -86px -65px;
    }
     
    div.blocTab th, td{
    border:2px solid white;
    text-align:center;
    padding:2px 10px;
    margin:0}
     
     
    div.blocTab tr{
    background-color:green;
    margin:0;
    padding:0;
    }
    div.blocTab tr.tr_imp{background-color:#dbe5f6;}
    div.blocTab select{
    margin:0;
    padding: 0 2px 2px 2px;
    }
     
     
    div.blocTab div.fix_table_body{
    height:10em;
    overflow-y:scroll;
    /*overflow-y:auto;*/
    overflow-x:visible;
    }
     
    div.blocTab div.fix_table_body  table{
    width:100%;
    /*width:auto;*/
    }
     
    	</style>
     
    	<script type="text/javascript" src="jquery-1.4.2.js"></script>
     
    	<script type="text/javascript"> 
    //<![CDATA[ 
     
     
    // code executé au demarrage
    $(document).ready(function(){   // Traitement à effectuer lorsque le DOM est prêt
    //$(window).load(function(){            // Traitement à effectuer lorsque tous les elements de la page sont chargés
     
            initFixedTable();
     
    });   
     
    // ******************************************************
    // creation des tableaux avec scrollbar verticale
    var widthColumn = []; // sert a redefinir la largeur des cases du tableau quand on le met a jour
    function initFixedTable(){
     
            var divDivTabList = $("div.fix_table");
            
            for (var i=0; i<divDivTabList.length; i++){ // parcours de tous les "div.fix_table"
            
                    var divTabList = $(divDivTabList[i]).children("div"); // récupération de de tous les "div.fix_table > div"
                    var tabHeader = $(divTabList[0]).children("table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_header > table"
                    var tabBody = $(divTabList[1]).find("div > table")[0]; // récupération de de tous les "div.fix_table > div.fix_table_body > div > table"
     
                    var tabHeaderLines = $(tabHeader).find("tr");
                    var tabBodyLines = $(tabBody).find("tr");
     
                    //alert(tabHeaderLines.length); // nombre de ligne              
                    //alert($(tabHeaderLines[0]).children().length); // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
     
                    
                    //var scrollBarWidth = getScrollerWidth();
                    
                    //var widthLine = $(tabHeaderLines[0]).width();
                    //var widthDiv = $(divTabList[0]).width();
                    //$(divTabList[1]).width(widthDiv + scrollBarWidth);
                    
                    //$(divTabList[0]).width(widthDiv);
                    
                    //$(tabBodyLines[0]).width(widthLine);
                    
                    //*
     
                    //*
                    var widthTabBody = $(tabBody).width();
                    //alert("get TabBody: " + widthTabBody);
                    $(tabHeader).width(widthTabBody); // +2 sur firefox
                    var widthTabHead = $(tabHeader).width();
                    //alert("get TabHead: " + widthTabHead);
                    
                    // le get width et le set width ne renvoit pas la meme chose
                    // => on corrige l'erreur
                    var diffWidth = widthTabBody - widthTabHead;
                    widthTabHead = widthTabBody + diffWidth;
                    
                    $(tabHeader).width(widthTabHead);
            
                    //if($(tabHeader).width() != $(tabBody).width()){
                    //      alert("get TabHead: " + $(tabHeader).width());
                    //      alert("get tabBody: " + $(tabBody).width());            
                    //} else {
                    //      alert("TabHead/tabBody width: OK");
                    //}
                    
                    $(tabBody).width(widthTabHead); // on fige aussi le body pour éviter tout problème si l'unité n'est pas de type absolue (ex : em)
                    
                    
                    //*             
                    // ************************************************
                    var headColumnCount = $(tabHeaderLines[0]).children().length; // nombre de colonnes de la première ligne (fonctionne pour thead et tbody)
                    var diffWidthColumn = [];
                    
                    for(j=0; j<headColumnCount; j++){
                            var columnTmp = $(tabHeaderLines[0]).children()[j];
                            widthColumn[j] = $(columnTmp).width(); //alert(widthColumn);
                    }
                    
            
                    //alert("set colonne width: " + widthColumn[0]);
                    $($(tabBodyLines[0]).children()[0]).width(widthColumn[0]);
                    //alert("get colonne width: " + $($(tabBodyLines[0]).children()[0]).width());
                    
                    diffWidthColumn = widthColumn[0] - $($(tabBodyLines[0]).children()[0]).width(); // calcul de la correction d'erreur
                    //alert(diffWidthColumn);
                    
                    for(j=0; j<headColumnCount; j++){
                    //for(j=0; j<1; j++){
                            widthColumn[j] += diffWidthColumn;
                            $($(tabBodyLines[0]).children()[j]).width(widthColumn[j]);
                            
                            // control d'erreur
                            //if ($($(tabHeaderLines[0]).children()[j]).width() != $($(tabBodyLines[0]).children()[j]).width()){
                            //      alert("Erreur0 largeur colonne: " + j);
                            //} else {
                            //      alert("largeur colonne OK: " + j);
                            //}
                    }
     
                    
                    // on fige aussi le head pour éviter tout problème si l'unité n'est pas de type absolue (ex : em)
                    for(j=0; j<headColumnCount; j++){
                            $($(tabHeaderLines[0]).children()[j]).width(widthColumn[j]);
                    }
                    
                    
                    // control d'erreur
                    //for(j=0; j<headColumnCount; j++){
                    //      if ($($(tabHeaderLines[0]).children()[j]).width() != $($(tabBodyLines[0]).children()[j]).width()){
                    //              alert("Erreur largeur colonne: " + j);
                    //      }
                    //}
                    // => TODO : on fait quoi si le tableau est vide ?
                    // */
     
                    
     
            }
    }
     
     
     
    //]]>
            </script>
     
    </head>
     
    <body style="min-width: 800px;">
     
    	<div id="corps">
    		<noscript><h1>Erreur : Javascript est désactivé</h1></noscript>
     
    			<div class="blocTab fix_table" id="tableLogBloc" style="float:clear;width:600px;">
    				<h3>Mon Titre</h3>
    				<div class="fix_table_header">
    					<table>
    						<thead>
    							<tr>
    								<th>ma colonne 1</th>
    								<th>ma colonne 2</th>
    								<th>ma colonne 3</th>
    								<th>ma colonne 4</th>
    							</tr>
    						</thead>
    						<tbody style="display:none"><tr><td></td></tr></tbody> <!-- pour etre valide W3C -->
    					</table>
    				</div>
     
    				<div class="fix_table_body" style="height:10em;">
    					<div style="height:100%;">
    						<table>
    							<tbody>
    								<tr>
    									<td>1</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    								<tr>
    									<td>2</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    								<tr>
    									<td>3</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    								<tr>
    									<td>4</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
     
    								<tr>
    									<td>5</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    								<tr>
    									<td>1</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    								<tr>
    									<td>2</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    								<tr>
    									<td>3</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    								<tr>
    									<td>4</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
     
    								<tr>
    									<td>5</td>
    									<td></td>
    									<td></td>
    									<td></td>
    								</tr>
     
    							</tbody>
    						</table>
    					</div>
    				</div>
    			</div>
    			<div class="spacer"></div>
     
    		</div>
     
    		<div class="spacer"><hr/></div>
    	</div>
     
    </body>
    </html>

    => par contre le plug-in datatables cité précédemment le fait sans ce div... il y a donc surement une meilleure solution que la mienne...

  15. #15
    Membre expérimenté
    Inscrit en
    Décembre 2009
    Messages
    282
    Détails du profil
    Informations forums :
    Inscription : Décembre 2009
    Messages : 282
    Par défaut
    En cherchant un peu j'ai trouvé ce plug-ins jQuery qui le fait : http://www.farinspace.com/jquery-scr...-table-plugin/

    Je ne l'ai pas du tout essayé donc je ne sais pas s'il marche sur tous les browsers....

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Comment fixer les largeurs des colonnes d'un TStrinGrid
    Par marsupilami34 dans le forum Composants VCL
    Réponses: 6
    Dernier message: 24/08/2005, 13h24
  2. forcer largeur de colonne qd URL chargee
    Par Batou dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 18/08/2005, 10h38
  3. Fixer la largeur des colonnes d'une CListCtrl
    Par Depteam1 dans le forum MFC
    Réponses: 4
    Dernier message: 28/06/2005, 15h46
  4. Largeur de colonne d'une ListView
    Par deaqu1 dans le forum IHM
    Réponses: 7
    Dernier message: 07/06/2005, 19h45
  5. [C#] Largeur de colonne et de ligne dans un DataGrid
    Par pc152 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 31/08/2004, 14h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo