2016-09-07 2 views
0

내가 반응 datatables데이터베이스 열 폭 기능은

$('#example').dataTable({ 
"columnDefs": [ 
{ "width": "20%", "targets": 0 } 
] 
}); 

고정 열 너비 https://datatables.net/reference/option/columns.width을 보관하려고하지만 열 텍스트가 강판 인 경우처럼 ("폭"로 지정된 것보다하고 작동하지 않습니다) 열 너비를 자동으로 크기 조정합니다. 필자는 어떻게 그것을 열 너비에 맞게 제한하고 줄임표를 사용하여 초과를 잘라낼 수 있습니까?

+0

세트'autoWidth : FALSE '는 놀라지하기 위해 모든 열'폭을 선언 기억합니다. – davidkonrad

+0

예를 들어 설명해 주시면 해결해 드릴 수 있습니다. – Peacefull

답변

0

당신에게이 CSS를 데이터 테이블에 추가하십시오 width: 100% !important;word-wrap: break-word; 그것은 당신을 위해 작동합니다.

<script> 

    $('#example').dataTable({ 
     "columnDefs": [ 
     { "width": "20%", "targets": [0] }], 
      fixedColumns: true 
     }); 

</script> 

.customDataTableLayout { 
    width: 100% !important; 
    word-wrap: break-word; 
} 

예컨대

<table class="customDataTableLayout" width="100%"> 
     <thead> 
     <tr> 
     <th>ID</th> 
     <th>student name</th> 
     <th>student Code</th> 
     <th>Status</th> 
     </tr> 
     </thead> 
    </table> 
+0

@ Arun kumar 만약 당신이 무엇이든 찾으면 나에게 업데이트하십시오. –

+0

시도해보십시오! –

+0

'.customDataTableLayout'을 선언하지만'# companyDataTable'을 참조합니다 - 어떻게 작동해야합니까? CSS에서 'width : 100 %! important;'를, 요소 속성으로 'width = "100 %"를 모두 갖는 점은 무엇입니까? – davidkonrad