angular-datatables : How to remove “Show N entries” but leave pagination

霸气de小男生 提交于 2019-12-24 15:24:15

问题


There is a project that uses angular-datatables. Now I need to remove "Show N entries" dropdown from a page with such table, but leave pagination untouched. For now i've found this way -

withOption('paging', false)

but this removes both!

Can anyone show me better way than just to remove them from DOM manually?


回答1:


Yes - paging removes both since there is no need for showing the lengthmenu if the table not is paginated. Use the lengthChange option to control whether the lengthmenu should be visible or not :

$scope.dtOptions = DTOptionsBuilder.newOptions()
                   .withOption('lengthChange', false);

demo -> http://plnkr.co/edit/0PnEwohCF9348uAf6OSD?p=preview




回答2:


Yes - paging removes both since there is no need for showing the lengthmenu if the table not is paginated. Use the [lengthChange][1] option to control whether the lengthmenu should be visible or not :

$scope.dtOptions = DTOptionsBuilder.newOptions()
                   .withOption('lengthChange', false);

demo -> http://plnkr.co/edit/TKMyZ1CLvDUazGGImiCd?p=preview

[1]: https://datatables.net/reference/option/lengthChange

it's still there.

vm.dtOptions = DTOptionsBuilder.newOptions().withPaginationType('full_numbers')
                                                    .withDisplayLength(10)
                                                    .withOption('lengthChange', false);



回答3:


You try add follow option to dtOptions:

.withLanguage({
            "sInfoFiltered": ""
        })


来源:https://stackoverflow.com/questions/32894201/angular-datatables-how-to-remove-show-n-entries-but-leave-pagination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!