8

プロダクトオーナーは、テーブルにデータがない場合に、空のテーブルにテーブルヘッダーのみを表示することを望んでいます。dataTableが「empty...」メッセージを含む行を作成するのを防ぐことはできないようです。

dataTableを初期化するために使用するコードは次のとおりです。私はここでいくつかのことが間違っていることを知っています。私は実験してきました。:)

$('#InBox').dataTable({
    "bFilter": false,
    "bPaginate": false,
    "bLengthChange": false,
    "bInfo": false,
    "oLanguage": {
        "sEmptyTable": '',
        "sInfoEmpty": ''
    }
});

これがdataTableのinit関数に入れようとしたコードですが、それを機能させる方法がわかりません。

/* Table is empty - create a row with an empty message in it */
            var anRows[0] = document.createElement('tr');

            if (typeof oSettings.asStripClasses[0] != 'undefined') {
                anRows[0].className = oSettings.asStripClasses[0];
            }

            var nTd = document.createElement('td');
            nTd.setAttribute('valign', "top");
            nTd.colSpan = oSettings.aoColumns.length;
            nTd.className = oSettings.oClasses.sRowEmpty;
            if (oSettings.fnRecordsTotal() > 0) {
                if (oSettings.oLanguage.sZeroFilterRecords.indexOf("_MAX_") != -1)
                    oSettings.oLanguage.sZeroFilterRecords = oSettings.oLanguage.sZeroFilterRecords.replace("_MAX_", oSettings.fnRecordsTotal());
                nTd.innerHTML = oSettings.oLanguage.sZeroFilterRecords;
            } else {
                nTd.innerHTML = oSettings.oLanguage.sZeroRecords;
            }

            anRows[iRowCount].appendChild(nTd);

ダン

4

5 に答える 5

8

これを試して

$('#InBox').dataTable({
  "bFilter": false,
   "bPaginate": false,
   "bLengthChange": false,
   "bInfo": false,
   "oLanguage": {
    "sEmptyTable": '',
    "sInfoEmpty": ''
   },
   "sEmptyTable": "There are no records",
 });

それ以外の場合は、これを試すことができます

$('#InBox').dataTable({
  "bFilter": false,
   "bPaginate": false,
   "bLengthChange": false,
   "bInfo": false,
   "oLanguage": {
    "sEmptyTable": '',
    "sInfoEmpty": ''
   }
 });
$('.dataTables_empty').html("No record found.");
于 2012-06-25T16:16:23.620 に答える
7

データテーブル プラグインから添付された tbody を削除する場合は、次の回避策を試すことができます。

$('.dataTables_empty').parent().parent().remove();
于 2015-10-15T18:20:58.373 に答える
2

oLanguage を使用して、DataTable プラグインをカスタマイズできます。

"oLanguage": { "sZeroRecords": "-Put customized text-", "sEmptyTable": "-Put customized text-" }

And if you want to remove those, just put these components into null:
"oLanguage": { "sZeroRecords": '', "sEmptyTable": '' }

それが役に立てば幸い!

于 2014-12-05T01:23:17.787 に答える