0

私はJQueryの初心者ですが、この部分については誰かの助けが必要です. テンプレートから動的テーブルを扱っています。ページ セクションごとに 10 レコードを削除したいのですが、その方法がわかりません。どなたかお願いします。

ここに私がまだ理解できるHTMLコードがあります

<table class="table table-striped border-top" id="sample_1">
        <thead>
          <tr>
            <!-- <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th> -->
            <th>No</th>
            <th>Name</th>
            <th class="hidden-phone">Name</th>
            <th class="hidden-phone">Text</th>
            <th class="hidden-phone">Text</th>
            <th class="hidden-phone">Text</th>
          </tr>
        </thead>
        <tbody>
          <tr class="odd gradeX">
            <!-- <td><input type="checkbox" class="checkboxes" value="1" /></td> -->
            <td>1</td>
            <td>Jhone doe</td>
            <td class="hidden-phone"><a href="mailto:jhone-doe@gmail.com">jhone-doe@gmail.com</a></td>
            <td class="hidden-phone">10</td>
            <td class="center hidden-phone">02.03.2013</td>
            <td class="hidden-phone"><span class="label label-success">Approved</span></td>
          </tr>
          <tr class="odd gradeX">
            <!-- <td><input type="checkbox" class="checkboxes" value="1" /></td> -->
            <td>2</td>
            <td>dipsdf</td>
            <td class="hidden-phone"><a href="mailto:soa bal@gmail.com">lorem-ip@gmail.com</a></td>
            <td class="hidden-phone">33</td>
            <td class="center hidden-phone">05.04.2013</td>
            <td class="hidden-phone"><span class="label label-success">Approved</span></td>
          </tr>
        </tbody>
      </table>

そこで何をしているのかわからないJqueryの部分

var Script = function () {

    // begin first table
    $('#sample_1').dataTable({
        "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
        "sPaginationType": "bootstrap",
        "oLanguage": {
            "sLengthMenu": "_MENU_ records per page",
            "oPaginate": {
                "sPrevious": "Prev",
                "sNext": "Next"
            }
        },
        "aoColumnDefs": [{
            'bSortable': false,
            'aTargets': [0]
        }]
    });

    jQuery('#sample_1 .group-checkable').change(function () {
        var set = jQuery(this).attr("data-set");
        var checked = jQuery(this).is(":checked");
        jQuery(set).each(function () {
            if (checked) {
                $(this).attr("checked", true);
            } else {
                $(this).attr("checked", false);
            }
        });
        jQuery.uniform.update(set);
    });

    jQuery('#sample_1_wrapper .dataTables_filter input').addClass("form-control"); // modify table search input
    jQuery('#sample_1_wrapper .dataTables_length select').addClass("form-control"); // modify table per page dropdown}();

ページセクションごとに10レコードを追加ボタンに置​​き換えながら、テーブルをデータベースの表示データにリンクしようとしています。どなたでもどうぞ。

感謝。

4

1 に答える 1

1

一度にすべてのレコードを一覧表示しようとしているだけの場合 (さらに、ページごとの表示数を変更するオプションを非表示にしている場合)、ページネーションを無効にする必要があります。

次のオプションを datatables 呼び出しに追加します。

"bPaginate": false

Datatable オプションの詳細については、こちらをご覧ください。

編集

「ページごと」オプションを非表示にするだけでページ分割したい場合は、代わりに次のオプションを使用してください。

"bLengthChange": false

JSFiddle

于 2013-11-19T16:08:21.190 に答える