2

デモは IE でのみ動作します

$(function ()
  {
      resolutionIndependentScroll(); 
      $("#tableList").colResizable({
            liveDrag: true,
            gripInnerHtml: "<div class='grip'></div>",
            draggingClass: "dragging"
      });
  });

スクロールと colResizalble テーブルのヘッダーを修正する必要があります。

4

3 に答える 3

2

@Means: 要件は、固定ヘッダー、列のサイズ変更可能、およびスクロールの 3 つです。
さらに、列の順序を切り替えたり、列を非表示/表示したりすることもできます。
この例は、それらすべてを満たします。
あなたの例を Flexigrid と組み合わせて使用​​しました。
何らかの理由で、jsFiddle へのリンクが正しく機能していません。なので、ローカルでテストしてください。
以下をダウンロードする必要があります。

  1. フレキシグリッド-1.1 パッケージ
  2. jquery-1.5.2.min.js

そして、それらを以下のようにローカルで使用するフォルダーに抽出しcssますjs:
flexigrid.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>  
    <link rel="stylesheet" type="text/css" href="css/flexigrid.pack.css" />
    <script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
    <script type="text/javascript" src="js/flexigrid.pack.js"></script>
    <script> 
        $(document).ready(function() {  $('.tableList').flexigrid();});
    </script>
</head>
<body>
    <table class="tableList" border="1">
        <thead>
            <tr>
                <th width="100" bgcolor="yellow">col1</th>
                <th width="100" bgcolor="yellow">col2</th>
                <th width="100" bgcolor="yellow">col3</th>
                <th width="100" bgcolor="yellow">col4</th>
                <th width="100" bgcolor="yellow">col5</th>
                <th width="100" bgcolor="yellow">col6</th>
                <th width="100" bgcolor="yellow">col7</th>
                <th width="100" bgcolor="yellow">col8</th>
                <th width="100" bgcolor="yellow">col9</th>
                <th width="100" bgcolor="yellow">col10</th>
                <th width="100" bgcolor="yellow">col11</th>
                <th width="100" bgcolor="yellow">col12</th>
                <th width="100" bgcolor="yellow">col13</th>
                <th width="100" bgcolor="yellow">col14</th>
                <th width="100" bgcolor="yellow">col15</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
            <tr>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
                <td>value</td>
            </tr>
        </tbody>
    </table>
</body>
</html>

お役に立てば幸いです。どんなコメントでも大歓迎です。ありがとう。

于 2013-03-22T20:18:19.587 に答える
1

そこにはたくさんのプラグインがあります..しかし、私の選択はjQgridです。

多くの機能とオプションを備えたプラグインです。また、固定ヘッダー、固定列、および列のサイズ変更もサポートしています >> http://www.trirand.com/blog/jqgrid/jqgrid.html << 詳細を試す -> サイズ変更。

これは最新のプラグインの 1 つですので、ぜひお試しください。

于 2013-03-25T14:02:38.247 に答える
1

最小限の要件として、DataTable.jsを使用できます

ここで、要件に応じてカスタム ライブ デモを見つけてください。

HTML

<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
        <tr>
            <th>Rendering engine</th>
            <th>Browser</th>
            <th>Platform(s)</th>
            <th>Engine version</th>
            <th>CSS grade</th>
        </tr>
    </thead>
    <tbody>
        <tr class="odd gradeX">
            <td>Trident</td>
            <td>Internet
                 Explorer 4.0</td>
            <td>Win 95+</td>
            <td class="center">4</td>
            <td class="center">X</td>
        </tr>
        <tr class="odd gradeC">
            <td>Trident</td>
            <td>Internet
                 Explorer 5.0</td>
            <td>Win 95+</td>
            <td class="center">5</td>
            <td class="center">C</td>
        </tr>
        <tr class="odd gradeA">
            <td>Trident</td>
            <td>Internet
                 Explorer 5.5</td>
            <td>Win 95+</td>
            <td class="center">5.5</td>
            <td class="center">A</td>
        </tr>
        <tr class="odd gradeA">
            <td>Trident</td>
            <td>Internet
                 Explorer 6</td>
            <td>Win 98+</td>
            <td class="center">6</td>
            <td class="center">A</td>
        </tr>
        <tr class="odd gradeA">
            <td>Trident</td>
            <td>Internet Explorer 7</td>
            <td>Win XP SP2+</td>
            <td class="center">7</td>
            <td class="center">A</td>
        </tr>
        <tr class="odd gradeA">
            <td>Trident</td>
            <td>AOL browser (AOL desktop)</td>
            <td>Win XP</td>
            <td class="center">6</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Firefox 1.0</td>
            <td>Win 98+ / OSX.2+</td>
            <td class="center">1.7</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Firefox 1.5</td>
            <td>Win 98+ / OSX.2+</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Firefox 2.0</td>
            <td>Win 98+ / OSX.2+</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Firefox 3.0</td>
            <td>Win 2k+ / OSX.3+</td>
            <td class="center">1.9</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Camino 1.0</td>
            <td>OSX.2+</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Camino 1.5</td>
            <td>OSX.3+</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Netscape 7.2</td>
            <td>Win 95+ / Mac OS 8.6-9.2</td>
            <td class="center">1.7</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Netscape Browser 8</td>
            <td>Win 98SE+</td>
            <td class="center">1.7</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Netscape Navigator 9</td>
            <td>Win 98+ / OSX.2+</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.0</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">1</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.1</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">1.1</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.2</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">1.2</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.3</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">1.3</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.4</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">1.4</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.5</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">1.5</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.6</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">1.6</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.7</td>
            <td>Win 98+ / OSX.1+</td>
            <td class="center">1.7</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Mozilla 1.8</td>
            <td>Win 98+ / OSX.1+</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Seamonkey 1.1</td>
            <td>Win 98+ / OSX.2+</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Gecko</td>
            <td>Epiphany 2.20</td>
            <td>Gnome</td>
            <td class="center">1.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Webkit</td>
            <td>Safari 1.2</td>
            <td>OSX.3</td>
            <td class="center">125.5</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Webkit</td>
            <td>Safari 1.3</td>
            <td>OSX.3</td>
            <td class="center">312.8</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Webkit</td>
            <td>Safari 2.0</td>
            <td>OSX.4+</td>
            <td class="center">419.3</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Webkit</td>
            <td>Safari 3.0</td>
            <td>OSX.4+</td>
            <td class="center">522.1</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Webkit</td>
            <td>OmniWeb 5.5</td>
            <td>OSX.4+</td>
            <td class="center">420</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Webkit</td>
            <td>iPod Touch / iPhone</td>
            <td>iPod</td>
            <td class="center">420.1</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Webkit</td>
            <td>S60</td>
            <td>S60</td>
            <td class="center">413</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera 7.0</td>
            <td>Win 95+ / OSX.1+</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera 7.5</td>
            <td>Win 95+ / OSX.2+</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera 8.0</td>
            <td>Win 95+ / OSX.2+</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera 8.5</td>
            <td>Win 95+ / OSX.2+</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera 9.0</td>
            <td>Win 95+ / OSX.3+</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera 9.2</td>
            <td>Win 88+ / OSX.3+</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera 9.5</td>
            <td>Win 88+ / OSX.3+</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Opera for Wii</td>
            <td>Wii</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Nokia N800</td>
            <td>N800</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>Presto</td>
            <td>Nintendo DS browser</td>
            <td>Nintendo DS</td>
            <td class="center">8.5</td>
            <td class="center">C/A<sup>1</sup></td>
        </tr>
        <tr class="gradeC">
            <td>KHTML</td>
            <td>Konqureror 3.1</td>
            <td>KDE 3.1</td>
            <td class="center">3.1</td>
            <td class="center">C</td>
        </tr>
        <tr class="gradeA">
            <td>KHTML</td>
            <td>Konqureror 3.3</td>
            <td>KDE 3.3</td>
            <td class="center">3.3</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeA">
            <td>KHTML</td>
            <td>Konqureror 3.5</td>
            <td>KDE 3.5</td>
            <td class="center">3.5</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeX">
            <td>Tasman</td>
            <td>Internet Explorer 4.5</td>
            <td>Mac OS 8-9</td>
            <td class="center">-</td>
            <td class="center">X</td>
        </tr>
        <tr class="gradeC">
            <td>Tasman</td>
            <td>Internet Explorer 5.1</td>
            <td>Mac OS 7.6-9</td>
            <td class="center">1</td>
            <td class="center">C</td>
        </tr>
        <tr class="gradeC">
            <td>Tasman</td>
            <td>Internet Explorer 5.2</td>
            <td>Mac OS 8-X</td>
            <td class="center">1</td>
            <td class="center">C</td>
        </tr>
        <tr class="gradeA">
            <td>Misc</td>
            <td>NetFront 3.1</td>
            <td>Embedded devices</td>
            <td class="center">-</td>
            <td class="center">C</td>
        </tr>
        <tr class="gradeA">
            <td>Misc</td>
            <td>NetFront 3.4</td>
            <td>Embedded devices</td>
            <td class="center">-</td>
            <td class="center">A</td>
        </tr>
        <tr class="gradeX">
            <td>Misc</td>
            <td>Dillo 0.8</td>
            <td>Embedded devices</td>
            <td class="center">-</td>
            <td class="center">X</td>
        </tr>
        <tr class="gradeX">
            <td>Misc</td>
            <td>Links</td>
            <td>Text only</td>
            <td class="center">-</td>
            <td class="center">X</td>
        </tr>
        <tr class="gradeX">
            <td>Misc</td>
            <td>Lynx</td>
            <td>Text only</td>
            <td class="center">-</td>
            <td class="center">X</td>
        </tr>
        <tr class="gradeC">
            <td>Misc</td>
            <td>IE Mobile</td>
            <td>Windows Mobile 6</td>
            <td class="center">-</td>
            <td class="center">C</td>
        </tr>
        <tr class="gradeC">
            <td>Misc</td>
            <td>PSP browser</td>
            <td>PSP</td>
            <td class="center">-</td>
            <td class="center">C</td>
        </tr>
        <tr class="gradeU">
            <td>Other browsers</td>
            <td>All others</td>
            <td>-</td>
            <td class="center">-</td>
            <td class="center">U</td>
        </tr>
    </tbody>
</table>

JavaScript

$(document).ready( function() {
    $('#example').dataTable( {
        "sDom": "Rlfrtip",
        "sScrollY": "200px",
        "bPaginate": false
    });
});

-------------------------------------------------- -------------------------------------------------- --------------------------------

より複雑なグリッド機能については、この単純なjqGridを使用できます。

jqGrid のカスタム デモはこちらです。

HTML

<table id="grid"></table>

JavaScript

var data = [[1, "Arcenal", "Barca"], 
            [2, "ManU", "Chelcea"],  
            [3, "RM", "Chelcea"],  
            [4, "ManU", "Arcenal"],  
            [5, "ManCity", "Chelcea"],  
            [6, "ManU", "ManCity"],  
            [7, "ManCity", "LiverPool"],  
            [8, "LiverPool", "Barca"], 
            [9, "RM", "Barca"],
            [10, "Chelcea", "LiverPool"]];

$("#grid").jqGrid({
    datatype: "local",
    height: 100,
    colNames: ['Match_no', 'Team1', 'Team2'],
    colModel: [{
        name: 'Match_no',
        index: 'Match_no',
        width: 60,
        sorttype: "int"},
    {
        name: 'Team1',
        index: 'Team1',
        width: 90,
        sorttype: "string"},
    {
        name: 'Team2',
        index: 'Team2',
        width: 90,
        sorttype: "string"}
    ],
    caption: "jqGrid sample demo",
});

var names = ["Match_no", "Team1", "Team2"];
var mydata = [];

for (var i = 0; i < data.length; i++) {
    mydata[i] = {};
    for (var j = 0; j < data[i].length; j++) {
        mydata[i][names[j]] = data[i][j];
    }
}

for (var i = 0; i <= mydata.length; i++) {
    $("#grid").jqGrid('addRowData', i + 1, mydata[i]);
}
于 2013-03-31T07:18:43.887 に答える