【问题标题】:How to add custom warning message on table empty or no match found in jquery datatable如何在 jquery 数据表中找到空表或未找到匹配项时添加自定义警告消息
【发布时间】:2013-12-09 12:14:42
【问题描述】:

我有 2 个数据表共享相同的 jquery-dataTables-js,因为我无法在 JavaScript 文件中更改它,有没有其他方法可以更改它

我想自定义默认错误消息。

未找到匹配记录 - 我们尚未添加任何内容 表格中没有可用数据 - 没有您选择的数据。

【问题讨论】:

    标签: javascript php jquery datatable warnings


    【解决方案1】:

    选中此项设置您的自定义消息。

    $(document).ready(function() {
        $('#data_table_id').DataTable( {
            "language": {
                "lengthMenu": "Display -- records per page",
                "zeroRecords": "No matching records found - We don't add anything yet No data available in table - no data of your choice.",
                "infoEmpty": "No records available"
            }
        } );
    } );
    

    【讨论】:

      【解决方案2】:

      请参阅此处http://datatables.net/usage/i18n 编辑默认数据表文本。还有一个例子http://datatables.net/examples/basic_init/language.html

      【讨论】:

        【解决方案3】:

        您也可以在initComplete 中进行操作,如下所示。在添加自定义类和设计方面更加灵活

        "initComplete": function(settings, json) {
        
                $('.dataTables_empty').html("<span class='label label-danger'>No records found</span>");
        
            }
        

        【讨论】:

          【解决方案4】:

          我正在使用 Datatable 1.10.12 和以下代码适用于我:

          "language": {
              "processing": '<div class="widget-loader" id="loader"><div class="load-dots"><span></span><span></span><span></span></div></div>',
              // show when no record found in a table...
              "emptyTable": '<h4 class="block text-center"><i class="fa fa-exclamation-triangle" style="color: #C49F47;"></i> {{ __("no_record_found") }}</h4>',
              // shown when no matching row found in filtering...
              "zeroRecords": '<h4 class="block text-center"><i class="fa fa-exclamation-triangle" style="color: #C49F47;"></i> {{ __("no_record_found") }}</h4>'
          }
          

          参考:How to show empty data message in Datatables

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2022-01-22
            • 2022-01-03
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-09-27
            • 2020-12-02
            相关资源
            最近更新 更多