2016-10-11 1 views
1

부트 스트랩 테이블의 모든 열을 표시하는 단추가 있습니다. 그것을 클릭하면 작동하지 않습니다.부트 스트랩 테이블 showAllColumns 메서드

코드 :

<table data-toggle="table"> 
     <thead> 
     <tr> 
      <th data-field="state" data-checkbox="true"></th> 
      <th data-field="id" >ID</th> 
      <th data-field="name">Name</th> 
     </tr> 
     </thead> 
    </table> 
    <button id="show_all">Show All columns</button> 
    <button id="hide_all">Hide All columns</button> 

<script>  

    $('#show_all').on('click', function(){ 
     $('table').bootstrapTable('showAllColumns'); 
    }) 

    $('#hide_all').on('click', function(){ 
     $('table').bootstrapTable('hideAllColumn'); 
    }) 

</script> 

의 예를 참조하십시오

여기

https://jsfiddle.net/ruzD/5b2vsdgy/

답변

0

는 작업 솔루션이다.

$('#show_all').on('click', function(){ 
    $('table th').show(); 
}) 

$('#hide_all').on('click', function(){ 
    $('table th').hide(); 
}) 
+0

이 솔루션은 테이블을 표시하거나 숨기지 만 문제는 아닙니다. 나는 테이블의 모든 컬럼을 보여주고 싶다. – ruzD

+0

이것은 당신의 테이블에있는 모든 것을 보여 주거나 숨 깁니다. 다른 것을 숨기고 싶다면 내 해결책을 편집 할 수 없다. –

+0

좋아, 더 많거나 적습니다. – ruzD