IT TIP

JQuery DataTable에서 기본적으로 모든 행을 표시하는 방법

itqueen 2020. 10. 17. 12:40
반응형

JQuery DataTable에서 기본적으로 모든 행을 표시하는 방법


아무도 jQuery 데이터 테이블에서 기본적으로 모든 행을 표시하는 방법을 알고 있습니까?

이 코드를 시도했지만 기본적으로 10 개의 행만 표시됩니다.

   $("#adminProducts").dataTable({
        "aLengthMenu": [100]
    });

사용하다:

$('#example').dataTable({
    aLengthMenu: [
        [25, 50, 100, 200, -1],
        [25, 50, 100, 200, "All"]
    ],
    iDisplayLength: -1
});

또는 1.10 이상을 사용하는 경우

$('#example').dataTable({
    paging: false
});

사용해야하는 옵션은 iDisplayLength입니다.

$('#adminProducts').dataTable({
  'iDisplayLength': 100
});

$('#table').DataTable({
   "lengthMenu": [ [5, 10, 25, 50, -1], [5, 10, 25, 50, "All"] ]
});

이것은 나를 위해 작동합니다.

    $(document).ready(function() {
    $('#example').DataTable( {
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
      } );
    } );

DataTables 1.10 이상을 사용하는 경우 <table>태그 에 data- * 속성을 사용할 수 있습니다.data-page-length="-1"

이는 아래와 같이 데이터 테이블 기본 구성에 "-1"이 정의되어 있다고 가정합니다.

$.extend(true, $.fn.dataTable.defaults, { 
    lengthMenu: [[10, 25, 50, 250, -1], [10, 25, 50, 250, "All"]]
});

자바 스크립트가 간단 해지 $("table").DataTables();며 HTML의 모든 표에 대한 표시를 사용자 정의 할 수 있습니다. IE. 같은 페이지에 10 행으로 제한되어야하는 두 번째 작은 테이블이있는 경우<table data-page-length="10">


'fnDrawCallback'사용

  $('#dataTable').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "fnInitComplete": function(){
            $('.display_results').show();
        },
        "fnDrawCallback": function() {
            $('.def').click(function(){
                var msg = $(this).next().text();
                $('.messages').messageBox()//Custom Dialog
            });
        }
})

다음은 .html 파일의 전체 기능 자바 스크립트입니다.

<!--- javascript -->
<script type="text/javascript">
  $(document).ready(function(){
    $('#sortable').dataTable({
        'iDisplayLength': 100
    })})
</script>

you have to download the bootstrap-table.min.js and make some modification to it..

  • If you download the bootstrap-table.min.js, just open it, and try to find "pageList:[10," make it as "pageList:[10,15,20,25,50,100,"All"]" make sure that "All" written as this.

  • Default page size can be changed as well from the same line "pageSize:10" you can change it as pageSize:"All".

  • Other options can be modified as well.

  • Don't forget to include it or linked to new place after completed your modification.

I hope it is clear and easy enough to be done.

참고URL : https://stackoverflow.com/questions/9443773/how-to-show-all-rows-by-default-in-jquery-datatable

반응형