如何在可显示的表格中显示未找到记录错误消息?

时间:2018-10-26 09:43:44

标签: javascript html5 datatables footable

当我从表中搜索值时,如果表中没有值,没有找到记录,我就使用了合适的表插件

<script src="{{URL::asset('plugins/bower_components/footable/js/footable.all.min.js')}}"></script>
    <script>
        var defaults = {
        paginate: true,
        pageSize: 25,
        pageNavigation: '.pagination',
        pageNavigationSize: 5, // mention the number how many page numbers you want to display.
        firstText: '&laquo;',
        previousText: '&lsaquo;',
        nextText: '&rsaquo;',
        lastText: '&raquo;',
        limitNavigation: 0,
        limitPreviousText: '...',
        limitNextText: '...'
    };
$('#demo-foo-row-toggler').footable();
// Search input
    $('#demo-foo-search').on('input', function(e) {
        e.preventDefault();
        filtering.trigger('footable_filter', { filter: $(this).val() });
    });
    </script>

1 个答案:

答案 0 :(得分:0)

添加一个空的div

<div style="display:none" id="norecord">No records found</div>

隐藏表格并显示div

 $(document).ready(function(){
       if ($.trim($("#demo-foo-row-toggler tbody").text()).length == 0) {
         $('#demo-foo-row-toggler').hide();
         $('#norecord').show();
       }                                           
    });

注意:页脚中没有默认选项